Skip to content

Commit 215ccfa

Browse files
committed
Added a test for a full block with authorization list. Also removed 1 transaction specific test
Signed-off-by: Roman <4833306+Filter94@users.noreply.github.com>
1 parent 091d83c commit 215ccfa

File tree

1 file changed

+197
-71
lines changed

1 file changed

+197
-71
lines changed

core/src/test/java/org/web3j/protocol/core/ResponseTest.java

Lines changed: 197 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,203 @@ void testEthBlockFullTransactionsWithBlob() {
12411241
assertEquals(ethBlock.getBlock(), (block));
12421242
}
12431243

1244+
@Test
1245+
void testEthBlockFullTransactionsWithAuthorizationList() {
1246+
1247+
buildResponse(
1248+
"{\n"
1249+
+ "\"id\":1,\n"
1250+
+ "\"jsonrpc\":\"2.0\",\n"
1251+
+ "\"result\": {\n"
1252+
+ " \"number\": \"0x1b4\",\n"
1253+
+ " \"hash\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
1254+
+ " \"parentHash\": \"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5\",\n"
1255+
+ " \"parentBeaconBlockRoot\": \"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169\",\n"
1256+
+ " \"nonce\": \"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2\",\n"
1257+
+ " \"sha3Uncles\": \"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\n"
1258+
+ " \"logsBloom\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
1259+
+ " \"transactionsRoot\": \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\n"
1260+
+ " \"stateRoot\": \"0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff\",\n"
1261+
+ " \"receiptsRoot\": \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\n"
1262+
+ " \"author\": \"0x1a95ad5ccdb0677af951810c6ddf4935afe4e5a6\",\n"
1263+
+ " \"miner\": \"0x4e65fda2159562a496f9f3522f89122a3088497a\",\n"
1264+
+ " \"mixHash\": \"0x57919c4e72e79ad7705a26e7ecd5a08ff546ac4fa37882e9cc57be87a3dab26b\",\n"
1265+
+ " \"difficulty\": \"0x027f07\",\n"
1266+
+ " \"totalDifficulty\": \"0x027f07\",\n"
1267+
+ " \"extraData\": \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n"
1268+
+ " \"size\": \"0x027f07\",\n"
1269+
+ " \"gasLimit\": \"0x9f759\",\n"
1270+
+ " \"gasUsed\": \"0x9f759\",\n"
1271+
+ " \"timestamp\": \"0x54e34e8e\",\n"
1272+
+ " \"transactions\": [{"
1273+
+ " \"hash\":\"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b\",\n"
1274+
+ " \"nonce\":\"0x1\",\n"
1275+
+ " \"blockHash\": \"0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b\",\n"
1276+
+ " \"blockNumber\": \"0x15df\",\n"
1277+
+ " \"chainId\": \"0x1\",\n"
1278+
+ " \"transactionIndex\": \"0x1\",\n"
1279+
+ " \"from\":\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\n"
1280+
+ " \"to\":\"0x85h43d8a49eeb85d32cf465507dd71d507100c1\",\n"
1281+
+ " \"value\":\"0x7f110\",\n"
1282+
+ " \"gas\": \"0x7f110\",\n"
1283+
+ " \"gasPrice\":\"0x09184e72a000\",\n"
1284+
+ " \"input\":\"0x\","
1285+
+ " \"creates\":null,\n"
1286+
+ " \"publicKey\":null,\n"
1287+
+ " \"raw\":null,\n"
1288+
+ " \"r\":\"0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc\",\n"
1289+
+ " \"s\":\"0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62\",\n"
1290+
+ " \"v\":\"0\",\n"
1291+
+ " \"yParity\": \"0x0\",\n"
1292+
+ " \"type\":\"0x4\",\n"
1293+
+ " \"maxFeePerGas\": \"0x7f110\",\n"
1294+
+ " \"maxPriorityFeePerGas\": \"0x7f110\",\n"
1295+
+ " \"authorizationList\": [{\n"
1296+
+ " \"chainId\": \"0x1\",\n"
1297+
+ " \"address\": \"0x7b73644935b8e68019ac6356c40661e1bc315860\",\n"
1298+
+ " \"nonce\": \"0x0\",\n"
1299+
+ " \"yParity\": \"0x1\",\n"
1300+
+ " \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n"
1301+
+ " \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\"\n"
1302+
+ " },{\n"
1303+
+ " \"chainId\": \"0x1\",\n"
1304+
+ " \"address\": \"0x1234567890123456789012345678901234567890\",\n"
1305+
+ " \"nonce\": \"0x5\",\n"
1306+
+ " \"yParity\": \"0x0\",\n"
1307+
+ " \"r\": \"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\",\n"
1308+
+ " \"s\": \"0x0987654321fedcba0987654321fedcba0987654321fedcba0987654321fedcba\"\n"
1309+
+ " }]"
1310+
+ " }], \n"
1311+
+ " \"uncles\": [\n"
1312+
+ " \"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\n"
1313+
+ " \"0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff\"\n"
1314+
+ " ],\n"
1315+
+ " \"sealFields\": [\n"
1316+
+ " \"0x57919c4e72e79ad7705a26e7ecd5a08ff546ac4fa37882e9cc57be87a3dab26b\",\n"
1317+
+ " \"0x39a3eb432fbef1fc\"\n"
1318+
+ " ],\n"
1319+
+ " \"baseFeePerGas\": \"0x7\",\n"
1320+
+ " \"withdrawalsRoot\": \"0x1b1f845cd61c375a89ef101fd1bd86355f372a6a3dfe1960f2355e70bd5cd8a2\",\n"
1321+
+ " \"withdrawals\": [\n"
1322+
+ " {\n"
1323+
+ " \"index\": \"0x68ba80\",\n"
1324+
+ " \"validatorIndex\": \"0x65285\",\n"
1325+
+ " \"address\": \"0x1e09b4199780a45792f4ff195ef68410a091b047\",\n"
1326+
+ " \"amount\": \"0xd1f129\"\n"
1327+
+ " }\n"
1328+
+ " ]\n"
1329+
+ " }\n"
1330+
+ "}");
1331+
1332+
EthBlock ethBlock = deserialiseResponse(EthBlock.class);
1333+
EthBlock.Block block =
1334+
new EthBlock.Block(
1335+
"0x1b4",
1336+
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
1337+
"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
1338+
"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169",
1339+
"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
1340+
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
1341+
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
1342+
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
1343+
"0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
1344+
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
1345+
"0x1a95ad5ccdb0677af951810c6ddf4935afe4e5a6",
1346+
"0x4e65fda2159562a496f9f3522f89122a3088497a",
1347+
"0x57919c4e72e79ad7705a26e7ecd5a08ff546ac4fa37882e9cc57be87a3dab26b",
1348+
"0x027f07",
1349+
"0x027f07",
1350+
"0x0000000000000000000000000000000000000000000000000000000000000000",
1351+
"0x027f07",
1352+
"0x9f759",
1353+
"0x9f759",
1354+
"0x54e34e8e",
1355+
Arrays.asList(
1356+
new EthBlock.TransactionObject(
1357+
"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
1358+
"0x1",
1359+
"0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b",
1360+
"0x15df",
1361+
"0x1",
1362+
"0x1",
1363+
"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
1364+
"0x85h43d8a49eeb85d32cf465507dd71d507100c1",
1365+
"0x7f110",
1366+
"0x09184e72a000",
1367+
"0x7f110",
1368+
"0x",
1369+
null,
1370+
null,
1371+
null,
1372+
"0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc",
1373+
"0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62",
1374+
0,
1375+
"0x0",
1376+
"0x4",
1377+
"0x7f110",
1378+
"0x7f110",
1379+
null,
1380+
null,
1381+
null,
1382+
Arrays.asList(
1383+
new AuthorizationTuple(
1384+
"0x1",
1385+
"0x7b73644935b8e68019ac6356c40661e1bc315860",
1386+
"0x0",
1387+
"0x1",
1388+
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
1389+
"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321"),
1390+
new AuthorizationTuple(
1391+
"0x1",
1392+
"0x1234567890123456789012345678901234567890",
1393+
"0x5",
1394+
"0x0",
1395+
"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
1396+
"0x0987654321fedcba0987654321fedcba0987654321fedcba0987654321fedcba")))),
1397+
Arrays.asList(
1398+
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
1399+
"0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff"),
1400+
Arrays.asList(
1401+
"0x57919c4e72e79ad7705a26e7ecd5a08ff546ac4fa37882e9cc57be87a3dab26b",
1402+
"0x39a3eb432fbef1fc"),
1403+
"0x7",
1404+
"0x1b1f845cd61c375a89ef101fd1bd86355f372a6a3dfe1960f2355e70bd5cd8a2",
1405+
Arrays.asList(
1406+
new EthBlock.Withdrawal(
1407+
"0x68ba80",
1408+
"0x65285",
1409+
"0x1e09b4199780a45792f4ff195ef68410a091b047",
1410+
"0xd1f129")),
1411+
null,
1412+
null);
1413+
1414+
assertEquals(ethBlock.getBlock(), (block));
1415+
1416+
// Verify the transaction's authorizationList was properly deserialized
1417+
EthBlock.TransactionObject tx =
1418+
(EthBlock.TransactionObject) ethBlock.getBlock().getTransactions().get(0).get();
1419+
assertNotNull(tx.getAuthorizationList());
1420+
assertEquals(2, tx.getAuthorizationList().size());
1421+
1422+
AuthorizationTuple auth1 = tx.getAuthorizationList().get(0);
1423+
assertEquals(BigInteger.ONE, auth1.getChainId());
1424+
assertEquals("0x7b73644935b8e68019ac6356c40661e1bc315860", auth1.getAddress());
1425+
assertEquals(BigInteger.ZERO, auth1.getNonce());
1426+
assertEquals(BigInteger.ONE, auth1.getYParity());
1427+
assertEquals(
1428+
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
1429+
auth1.getRRaw());
1430+
assertEquals(
1431+
"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
1432+
auth1.getSRaw());
1433+
1434+
AuthorizationTuple auth2 = tx.getAuthorizationList().get(1);
1435+
assertEquals(BigInteger.ONE, auth2.getChainId());
1436+
assertEquals("0x1234567890123456789012345678901234567890", auth2.getAddress());
1437+
assertEquals(BigInteger.valueOf(5), auth2.getNonce());
1438+
assertEquals(BigInteger.ZERO, auth2.getYParity());
1439+
}
1440+
12441441
@Test
12451442
void testEthBlockNull() {
12461443
buildResponse("{\n" + " \"result\": null\n" + "}");
@@ -1430,77 +1627,6 @@ void testEthTransactionNull() {
14301627
assertEquals(ethTransaction.getTransaction(), (Optional.empty()));
14311628
}
14321629

1433-
@Test
1434-
void testEthTransactionWithAuthorizationList() {
1435-
buildResponse(
1436-
"{\n"
1437-
+ " \"id\":1,\n"
1438-
+ " \"jsonrpc\":\"2.0\",\n"
1439-
+ " \"result\": {\n"
1440-
+ " \"hash\":\"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b\",\n"
1441-
+ " \"nonce\":\"0x1\",\n"
1442-
+ " \"blockHash\": \"0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b\",\n"
1443-
+ " \"blockNumber\": \"0x15df\",\n"
1444-
+ " \"chainId\": \"0x1\",\n"
1445-
+ " \"transactionIndex\": \"0x1\",\n"
1446-
+ " \"from\":\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\n"
1447-
+ " \"to\":\"0x85h43d8a49eeb85d32cf465507dd71d507100c1\",\n"
1448-
+ " \"value\":\"0x7f110\",\n"
1449-
+ " \"gas\": \"0x7f110\",\n"
1450-
+ " \"gasPrice\":\"0x09184e72a000\",\n"
1451-
+ " \"input\":\"0x\",\n"
1452-
+ " \"r\":\"0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc\",\n"
1453-
+ " \"s\":\"0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62\",\n"
1454-
+ " \"v\":\"0x0\",\n"
1455-
+ " \"yParity\":\"0x0\",\n"
1456-
+ " \"type\":\"0x4\",\n"
1457-
+ " \"authorizationList\": [{\n"
1458-
+ " \"chainId\": \"0x1\",\n"
1459-
+ " \"address\": \"0x7b73644935b8e68019ac6356c40661e1bc315860\",\n"
1460-
+ " \"nonce\": \"0x0\",\n"
1461-
+ " \"yParity\": \"0x1\",\n"
1462-
+ " \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n"
1463-
+ " \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\"\n"
1464-
+ " },{\n"
1465-
+ " \"chainId\": \"0x1\",\n"
1466-
+ " \"address\": \"0x1234567890123456789012345678901234567890\",\n"
1467-
+ " \"nonce\": \"0x5\",\n"
1468-
+ " \"yParity\": \"0x0\",\n"
1469-
+ " \"r\": \"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\",\n"
1470-
+ " \"s\": \"0x0987654321fedcba0987654321fedcba0987654321fedcba0987654321fedcba\"\n"
1471-
+ " }]\n"
1472-
+ " }\n"
1473-
+ "}");
1474-
1475-
EthTransaction ethTransaction = deserialiseResponse(EthTransaction.class);
1476-
Transaction tx = ethTransaction.getTransaction().get();
1477-
1478-
assertEquals(
1479-
"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", tx.getHash());
1480-
assertEquals("0x4", tx.getType());
1481-
1482-
assertNotNull(tx.getAuthorizationList());
1483-
assertEquals(2, tx.getAuthorizationList().size());
1484-
1485-
AuthorizationTuple auth1 = tx.getAuthorizationList().get(0);
1486-
assertEquals(BigInteger.ONE, auth1.getChainId());
1487-
assertEquals("0x7b73644935b8e68019ac6356c40661e1bc315860", auth1.getAddress());
1488-
assertEquals(BigInteger.ZERO, auth1.getNonce());
1489-
assertEquals(BigInteger.ONE, auth1.getYParity());
1490-
assertEquals(
1491-
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
1492-
auth1.getRRaw());
1493-
assertEquals(
1494-
"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
1495-
auth1.getSRaw());
1496-
1497-
AuthorizationTuple auth2 = tx.getAuthorizationList().get(1);
1498-
assertEquals(BigInteger.ONE, auth2.getChainId());
1499-
assertEquals("0x1234567890123456789012345678901234567890", auth2.getAddress());
1500-
assertEquals(BigInteger.valueOf(5), auth2.getNonce());
1501-
assertEquals(BigInteger.ZERO, auth2.getYParity());
1502-
}
1503-
15041630
@Test
15051631
void testEthTransactionWithEmptyAuthorizationList() {
15061632
buildResponse(

0 commit comments

Comments
 (0)