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

feat: create second batch of additional conformity tests #2889

Merged
merged 2 commits into from
Aug 29, 2024
Merged
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
151 changes: 150 additions & 1 deletion packages/server/tests/acceptance/conformityTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async function signAndSendRawTransaction(transaction) {
blockHash: transactionReceipt.result.blockHash,
transactionIndex: transactionReceipt.result.transactionIndex,
blockNumber: transactionReceipt.result.blockNumber,
contractAddress: transactionReceipt.result.contractAddress,
};
}

Expand Down Expand Up @@ -325,7 +326,7 @@ async function processFileContent(directory, file, content) {
expect(valid).to.be.true;
}

describe('@api-conformity Ethereum execution apis tests', function () {
describe('@api-conformity @conformity-batch-1 Ethereum execution apis tests', function () {
this.timeout(240 * 1000);
before(async () => {
legacyTransactionAndBlockHash = await signAndSendRawTransaction(legacyTransaction);
Expand Down Expand Up @@ -364,3 +365,151 @@ describe('@api-conformity Ethereum execution apis tests', function () {
}
}
});

describe('@api-conformity @conformity-batch-2 Ethereum execution apis tests', async function () {
this.timeout(240 * 1000);

let existingBlockFilter: string;
let existingContractFilter: string;

before(async () => {
existingBlockFilter = (
await sendRequestToRelay(
{
jsonrpc: '2.0',
method: 'eth_newBlockFilter',
params: [],
id: 1,
},
false,
)
).result;

const deployLogsContractTx = await signAndSendRawTransaction({
chainId: 0x12a,
to: null,
from: sendAccountAddress,
maxPriorityFeePerGas: gasPrice,
maxFeePerGas: gasPrice,
gasLimit: gasLimit,
type: 2,
// Logs.sol bytecode
data: '0x608060405234801561000f575f80fd5b506102668061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610055575f3560e01c80632a4c08961461005957806378b9a1f31461006e578063c670f86414610081578063c683d6a314610094578063d05285d4146100a7575b5f80fd5b61006c6100673660046101a1565b6100ba565b005b61006c61007c3660046101ca565b6100ee565b61006c61008f3660046101ea565b61011e565b61006c6100a2366004610201565b61014b565b61006c6100b53660046101ea565b61018d565b8082847fa8fb2f9a49afc2ea148319326c7208965555151db2ce137c05174098730aedc360405160405180910390a4505050565b604051819083907f513dad7582fd8b11c8f4d05e6e7ac8caaa5eb690e9173dd2bed96b5ae0e0d024905f90a35050565b60405181907f46692c0e59ca9cd1ad8f984a9d11715ec83424398b7eed4e05c8ce84662415a8905f90a250565b8183857f75e7d95cd72588af49ce2e4b7f004bce916d422999adf262a640e4239aab00c78460405161017f91815260200190565b60405180910390a450505050565b60405181815260200160405180910390a050565b5f805f606084860312156101b3575f80fd5b505081359360208301359350604090920135919050565b5f80604083850312156101db575f80fd5b50508035926020909101359150565b5f602082840312156101fa575f80fd5b5035919050565b5f805f8060808587031215610214575f80fd5b505082359460208401359450604084013593606001359250905056fea2646970667358221220b05dc9ca2bdac3ef22d07be796918cdf20a8ed1cdbba3e2d335b1487e0e5221f64736f6c63430008180033',
});

existingContractFilter = (
await sendRequestToRelay(
{
jsonrpc: '2.0',
method: 'eth_newFilter',
params: [
{
fromBlock: '0x1',
toBlock: '0x160c',
address: deployLogsContractTx.contractAddress,
},
],
id: 1,
},
false,
)
).result;
});

const TEST_CASES = {
eth_submitHashrate: {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_submitHashrate"}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32601}}',
},
eth_sign: {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_sign"}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32601}}',
},
eth_signTransaction: {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_signTransaction"}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32601}}',
},
eth_sendTransaction: {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_sendTransaction"}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32601}}',
},
eth_protocolVersion: {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_protocolVersion"}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32601}}',
},
eth_newPendingTransactionFilter: {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_newPendingTransactionFilter"}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32601}}',
},
eth_newBlockFilter: {
request: '{"jsonrpc":"2.0","id":1,"method":"eth_newBlockFilter"}',
response: '{"jsonrpc":"2.0","id":1,"result":"0x33f5c9d2974eea142909a19906ef0548"}',
},
'eth_getFilterChanges - existing filter': {
konstantinabl marked this conversation as resolved.
Show resolved Hide resolved
request:
'{"jsonrpc":"2.0","id":1,"method":"eth_getFilterChanges","params":["0xb5c45fa0ece1ff79b115fc7cc490655b"]}',
response:
'{"jsonrpc":"2.0","id":1,"result":["0xc926f266c4a93e01cf6df220b5902b032adb38d70626835d8f53c9f8a648d747dd651af5e9c64201aad121a93c2304c4"]}',
},
'eth_getFilterChanges - no existing filter': {
status: 400,
request:
'{"jsonrpc":"2.0","id":1,"method":"eth_getFilterChanges","params":["0x275220eef57cfbc06e932e043535d492"]}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32001}}',
},
eth_uninstallFilter: {
request:
'{"jsonrpc":"2.0","id":1,"method":"eth_uninstallFilter","params":["0x275220eef57cfbc06e932e043535d492"]}',
response: '{"jsonrpc":"2.0","id":1,"result":false}',
},
eth_newFilter: {
request:
'{"jsonrpc":"2.0","id":1,"method":"eth_newFilter","params":[{"fromBlock": "0x1","toBlock": "0x160c","address": "0x281723C907113cbdEe8785F3480dD7496315312c"}]}',
response: '{"jsonrpc":"2.0","id":1,"result":"0xd569b8fad2873edebd3033831f790dee"}',
},
'eth_getFilterLogs - existing filter': {
request: '{"jsonrpc":"2.0","id":1,"method":"eth_getFilterLogs","params":["0x65d84e9904db339e6a85340b9f7c3d3e"]}',
response: '{"jsonrpc":"2.0","id":1,"result":[]}',
},
'eth_getFilterLogs - no existing filter': {
status: 400,
request: '{"jsonrpc":"2.0","id":1,"method":"eth_getFilterLogs","params":["0xb567d26e162027d80fd434e3bc3d6897"]}',
response: '{"jsonrpc":"2.0","id":1,"error":{"code":-32001}}',
},
};

for (const TEST_NAME in TEST_CASES) {
it(`${TEST_NAME}`, async () => {
const isErrorStatusExpected: boolean = !!(TEST_CASES[TEST_NAME]?.status && TEST_CASES[TEST_NAME].status != 200);
try {
const req = updateParamIfNeeded(TEST_NAME, JSON.parse(TEST_CASES[TEST_NAME].request));
const res = await sendRequestToRelay(req, false);
const hasMissingKeys: boolean = checkResponseFormat(res, JSON.parse(TEST_CASES[TEST_NAME].response));
expect(hasMissingKeys).to.be.false;
expect(isErrorStatusExpected).to.be.false;
} catch (e: any) {
expect(isErrorStatusExpected).to.be.true;
expect(e?.response?.status).to.equal(TEST_CASES[TEST_NAME].status);
}
});
}

const updateParamIfNeeded = (testName, request) => {
switch (testName) {
case 'eth_getFilterChanges - existing filter':
request.params = [existingBlockFilter];
break;
case 'eth_getFilterLogs - existing filter':
request.params = [existingContractFilter];
break;
}

return request;
};
});
Loading