Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 smoke tests #1327

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/src/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ import {
import {CallsV1} from "./v1/Calls.sol";
import {HandlersV1} from "./v1/Handlers.sol";

import {InboundMessageV2, Command as CommandV2, CommandKind} from "./v2/Types.sol";
import {InboundMessageV2, CommandV2, CommandKind} from "./v2/Types.sol";
import {CallsV2} from "./v2/Calls.sol";
import {HandlersV2} from "./v2/Handlers.sol";
4 changes: 2 additions & 2 deletions contracts/src/v2/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ struct InboundMessageV2 {
// Message nonce
uint64 nonce;
// Commands
Command[] commands;
CommandV2[] commands;
}

struct Command {
struct CommandV2 {
uint8 kind;
uint64 gas;
bytes payload;
Expand Down
29 changes: 29 additions & 0 deletions contracts/test/GatewayV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,33 @@ contract GatewayV2Test is Test {
message, proof, makeMockProof(), relayerRewardAddress
);
}

function testEncodeDecodeMessageV2() public {
UnlockNativeTokenParams memory params = UnlockNativeTokenParams({
token: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,
recipient: 0xEDa338E4dC46038493b885327842fD3E301CaB39,
amount: 1_000_000
});
bytes memory encoded = abi.encode(params);
CommandV2[] memory commands = new CommandV2[](1);
commands[0] = CommandV2({
kind: CommandKind.UnlockNativeToken,
gas: 100_000,
payload: encoded
});
InboundMessageV2 memory message = InboundMessageV2({
origin: bytes32(uint256(1000)),
nonce: 1,
commands: commands
});
bytes memory rawBytes = abi.encode(message);

//From OutboundQueueV2
bytes memory data = abi.encodePacked(
hex"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000186a000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000eda338e4dc46038493b885327842fd3e301cab3900000000000000000000000000000000000000000000000000000000000f4240"
);
assertEq(data, rawBytes);
InboundMessageV2 memory result = abi.decode(data, (InboundMessageV2));
assertEq(result.nonce, 1);
}
}
8 changes: 4 additions & 4 deletions relayer/contracts/gateway.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions relayer/relays/parachain/types_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ type CommandWrapper struct {
Params types.Bytes
}

func (r CommandWrapper) IntoCommandV2() contracts.Command {
return contracts.Command{
func (r CommandWrapper) IntoCommandV2() contracts.CommandV2 {
return contracts.CommandV2{
Kind: uint8(r.Kind),
Gas: uint64(r.MaxDispatchGas),
Payload: r.Params,
}
}

func (m OutboundQueueMessageV2) IntoInboundMessageV2() contracts.InboundMessageV2 {
var commands []contracts.Command
var commands []contracts.CommandV2
for _, command := range m.Commands {
commands = append(commands, command.IntoCommandV2())
}
Expand Down
Loading
Loading