@@ -238,6 +238,16 @@ contract Decode is HubSolanaSpokeVoteDecoderTest, ProposalTest {
238
238
* (10 ** (hubSolanaSpokeVoteDecoder.HUB_TOKEN_DECIMALS () - hubSolanaSpokeVoteDecoder.SOLANA_TOKEN_DECIMALS ()));
239
239
}
240
240
241
+ function _reverse (uint64 input ) internal pure returns (uint64 v ) {
242
+ v = input;
243
+ // swap bytes
244
+ v = ((v & 0xFF00FF00FF00FF00 ) >> 8 ) | ((v & 0x00FF00FF00FF00FF ) << 8 );
245
+ // swap 2-byte long pairs
246
+ v = ((v & 0xFFFF0000FFFF0000 ) >> 16 ) | ((v & 0x0000FFFF0000FFFF ) << 16 );
247
+ // swap 4-byte long pairs
248
+ v = (v >> 32 ) | (v << 32 );
249
+ }
250
+
241
251
function testFuzz_CorrectlyParseChainResponse (
242
252
uint64 _againstVotes ,
243
253
uint64 _forVotes ,
@@ -261,9 +271,9 @@ contract Decode is HubSolanaSpokeVoteDecoderTest, ProposalTest {
261
271
262
272
assertEq (queryVote.proposalId, proposalId, "Proposal ID mismatch " );
263
273
assertEq (queryVote.spokeProposalId, keccak256 (abi.encode (SPOKE_CHAIN_ID, proposalId)), "Spoke proposal ID mismatch " );
264
- assertEq (queryVote.proposalVote.abstainVotes, _scale (_abstainVotes), "Abstain votes mismatch " );
265
- assertEq (queryVote.proposalVote.againstVotes, _scale (_againstVotes), "Against votes mismatch " );
266
- assertEq (queryVote.proposalVote.forVotes, _scale (_forVotes), "For votes mismatch " );
274
+ assertEq (queryVote.proposalVote.abstainVotes, _scale (_reverse ( _abstainVotes) ), "Abstain votes mismatch " );
275
+ assertEq (queryVote.proposalVote.againstVotes, _scale (_reverse ( _againstVotes) ), "Against votes mismatch " );
276
+ assertEq (queryVote.proposalVote.forVotes, _scale (_reverse ( _forVotes) ), "For votes mismatch " );
267
277
assertEq (queryVote.chainId, SPOKE_CHAIN_ID, "Chain ID mismatch " );
268
278
}
269
279
0 commit comments