Skip to content

Commit 3f45ce1

Browse files
committed
evm/governance: add deserialisation test from guardian dump
1 parent 534458d commit 3f45ce1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

evm/test/wormhole/Governance.t.sol

+28
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ contract GovernanceTest is Test {
4141
myContract.transferOwnership(address(governance));
4242
}
4343

44+
function test_parseGuardian() public {
45+
// these bytes were dumped from the guardian command with prototxt
46+
// ```
47+
// current_set_index: 4
48+
// # generic evm call
49+
// messages: {
50+
// sequence: 4513077582118919631
51+
// nonce: 2809988562
52+
// evm_call: {
53+
// chain_id: 3
54+
// governance_contract: "0xD8E4C2DbDd2e2bd8F1336EA691dBFF6952B1a6eB"
55+
// target_contract: "0xF890982f9310df57d00f659cf4fd87e65adEd8d7"
56+
// abi_encoded_call: "BEEFFACE"
57+
// }
58+
// }
59+
// ```
60+
bytes memory foo =
61+
hex"000000000000000047656e6572616c507572706f7365476f7665726e616e6365010003d8e4c2dbdd2e2bd8f1336ea691dbff6952b1a6ebf890982f9310df57d00f659cf4fd87e65aded8d70004beefface";
62+
Governance.GeneralPurposeGovernanceMessage memory message =
63+
governance.parseGeneralPurposeGovernanceMessage(foo);
64+
assertEq(message.action, uint8(Governance.GovernanceAction.EVM_CALL));
65+
assertEq(message.chain, uint16(3));
66+
assertEq(message.governanceContract, address(0xD8E4C2DbDd2e2bd8F1336EA691dBFF6952B1a6eB));
67+
assertEq(message.governedContract, address(0xF890982f9310df57d00f659cf4fd87e65adEd8d7));
68+
console.logBytes(message.callData);
69+
assertEq(message.callData, hex"beefface");
70+
}
71+
4472
function buildGovernanceVaa(
4573
uint8 action,
4674
uint16 chainId,

0 commit comments

Comments
 (0)