Skip to content

Commit

Permalink
update RLP Tx tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed Jan 17, 2024
1 parent f4e03fb commit b786cfa
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions test/Transactions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ contract TestTransactions is Test {
value: 10,
nonce: 0,
data: bytes(""),
chainId: 0,
v: abi.encodePacked(hex"1b"),
r: abi.encodePacked(hex"9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f"),
s: abi.encodePacked(hex"8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1")
chainId: 0
});

bytes memory expected = abi.encodePacked(
hex"f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1"
hex"df800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a80808080"
);
_testLegacyTransaction(txnWithToAddress, expected);

Expand All @@ -33,19 +30,17 @@ contract TestTransactions is Test {
value: 10,
nonce: 1,
data: abi.encodePacked(hex"02"),
chainId: 0,
v: abi.encodePacked(hex"1b"),
r: abi.encodePacked(hex"754a33a9c37cfcf61cd61939fd93f5fe194b7d1ee6ef07490e8c880f3bd0d87d"),
s: abi.encodePacked(hex"715bd50fa2c24e2ce0ea595025a44a39ac238558882f9f07dd885ddc51839419")
chainId: 0
});

expected = abi.encodePacked(
hex"f84b010a82c350800a021ba0754a33a9c37cfcf61cd61939fd93f5fe194b7d1ee6ef07490e8c880f3bd0d87da0715bd50fa2c24e2ce0ea595025a44a39ac238558882f9f07dd885ddc51839419"
);
expected = abi.encodePacked(hex"cb010a82c350800a02808080");
_testLegacyTransaction(txnWithoutToAddress, expected);
}

function _testLegacyTransaction(Transactions.Legacy memory legacyTxn, bytes memory expectedRlp) public {
function _testLegacyTransaction(
Transactions.Legacy memory legacyTxn,
bytes memory expectedRlp
) public {
bytes memory rlp = Transactions.encodeRLP(legacyTxn);
assertEq0(rlp, expectedRlp);

Expand Down

0 comments on commit b786cfa

Please sign in to comment.