Skip to content

Commit

Permalink
feat: readding debug_getRawTransaction and debug_traceTransaction tes…
Browse files Browse the repository at this point in the history
…ts for contract methods
  • Loading branch information
IdrisHanafi committed Nov 15, 2023
1 parent e1ed883 commit 73b3e0e
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 11 deletions.
28 changes: 21 additions & 7 deletions cmd/rpcfuzz/rpcfuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ func setupTests(ctx context.Context, rpcClient *rpc.Client) {
Method: "eth_getCode",
Args: []interface{}{*testContractAddress, "latest"},
Flags: FlagStrictValidation,
Validator: ValidateHashedResponse("b0fcd1e4aaa20c969efc530a752fd177d61e1b20"),
Validator: ValidateHashedResponse("b9689c32bf9284029715ff8375f8996129898db9"),
})
allTests = append(allTests, &RPCTestGeneric{
Name: "RPCTestEthGetCodePending",
Method: "eth_getCode",
Args: []interface{}{*testContractAddress, "pending"},
Flags: FlagStrictValidation,
Validator: ValidateHashedResponse("b0fcd1e4aaa20c969efc530a752fd177d61e1b20"),
Validator: ValidateHashedResponse("b9689c32bf9284029715ff8375f8996129898db9"),
})
allTests = append(allTests, &RPCTestGeneric{
Name: "RPCTestEthGetCodeEarliest",
Expand Down Expand Up @@ -843,8 +843,7 @@ func setupTests(ctx context.Context, rpcClient *rpc.Client) {
allTests = append(allTests, &RPCTestDynamicArgs{
Name: "RPCTestEthGetTransactionByBlockNumberAndIndex",
Method: "eth_getTransactionByBlockNumberAndIndex",
// Args: ArgsTransactionBlockNumberAndIndex(ctx, rpcClient, &RPCTestTransactionArgs{To: *testContractAddress, Value: "0x0", Data: "0xa0712d680000000000000000000000000000000000000000000000000000000000002710", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas, Gas: defaultGas}),
Args: ArgsTransactionBlockNumberAndIndex(ctx, rpcClient, &RPCTestTransactionArgs{To: testEthAddress.String(), Value: "0x123", Gas: "0x5208", Data: "0x", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas}),
Args: ArgsTransactionBlockNumberAndIndex(ctx, rpcClient, &RPCTestTransactionArgs{To: testEthAddress.String(), Value: "0x123", Gas: "0x5208", Data: "0x", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas}),
Validator: RequireAll(
ValidateJSONSchema(rpctypes.RPCSchemaEthTransaction),
ValidateTransactionHash(),
Expand All @@ -853,9 +852,8 @@ func setupTests(ctx context.Context, rpcClient *rpc.Client) {

// cast receipt --rpc-url localhost:8545 0x1bd4ec642302aa22906360af6493c230ecc41df10fffcdedc85caeb22cbb6b58
allTests = append(allTests, &RPCTestDynamicArgs{
Name: "RPCTestGetTransactionReceipt",
Method: "eth_getTransactionReceipt",
// Args: ArgsTransactionHash(ctx, rpcClient, &RPCTestTransactionArgs{To: *testContractAddress, Value: "0x0", Data: "0xa0712d680000000000000000000000000000000000000000000000000000000000002710", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas, Gas: defaultGas}),
Name: "RPCTestGetTransactionReceipt",
Method: "eth_getTransactionReceipt",
Args: ArgsTransactionHash(ctx, rpcClient, &RPCTestTransactionArgs{To: testEthAddress.String(), Value: "0x123", Gas: "0x5208", Data: "0x", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas}),
Validator: ValidateJSONSchema(rpctypes.RPCSchemaEthReceipt),
})
Expand Down Expand Up @@ -1105,6 +1103,14 @@ func setupTests(ctx context.Context, rpcClient *rpc.Client) {
Args: ArgsTransactionHash(ctx, rpcClient, &RPCTestTransactionArgs{To: *testContractAddress, Value: "0x0", Data: "0x06fdde03", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas, Gas: defaultGas}),
Validator: ValidateJSONSchema(rpctypes.RPCSchemaDebugTrace),
})
// cast calldata "deposit(uint256)" 1
// 0xb6b55f250000000000000000000000000000000000000000000000000000000000000001
allTests = append(allTests, &RPCTestDynamicArgs{
Name: "RPCTestDebugTraceTransactionDeposit",
Method: "debug_traceTransaction",
Args: ArgsTransactionHash(ctx, rpcClient, &RPCTestTransactionArgs{To: *testContractAddress, Value: "0x0", Data: "0xb6b55f250000000000000000000000000000000000000000000000000000000000000001", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas, Gas: defaultGas}),
Validator: ValidateJSONSchema(rpctypes.RPCSchemaDebugTrace),
})

// cast rpc --rpc-url localhost:8545 debug_getRawBlock latest
allTests = append(allTests, &RPCTestGeneric{
Expand Down Expand Up @@ -1201,6 +1207,14 @@ func setupTests(ctx context.Context, rpcClient *rpc.Client) {
Args: ArgsTransactionHash(ctx, rpcClient, &RPCTestTransactionArgs{To: testEthAddress.String(), Value: "0x123", Gas: "0x5208", Data: "0x", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas}),
Validator: ValidateRegexString(`^0x[0-9a-f]*`),
})
// cast calldata "deposit(uint256)" 1
// 0xb6b55f250000000000000000000000000000000000000000000000000000000000000001
allTests = append(allTests, &RPCTestDynamicArgs{
Name: "RPCTestDebugGetRawTransactionDeposit",
Method: "debug_getRawTransaction",
Args: ArgsTransactionHash(ctx, rpcClient, &RPCTestTransactionArgs{To: *testContractAddress, Value: "0x0", Data: "0xb6b55f250000000000000000000000000000000000000000000000000000000000000001", MaxFeePerGas: defaultMaxFeePerGas, MaxPriorityFeePerGas: defaultMaxPriorityFeePerGas, Gas: defaultGas}),
Validator: ValidateRegexString(`^0x[0-9a-f]*`),
})

// cast rpc --rpc-url localhost:8545 debug_traceBlockByNumber 0x0
// cast rpc --rpc-url localhost:8545 debug_traceBlockByNumber 0x1
Expand Down
2 changes: 1 addition & 1 deletion contracts/conformancetester/ConformanceTester.abi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"RevertErrorMessage","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"testRevert","outputs":[],"stateMutability":"pure","type":"function"}]
[{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"RevertErrorMessage","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"testRevert","outputs":[],"stateMutability":"pure","type":"function"}]
2 changes: 1 addition & 1 deletion contracts/conformancetester/ConformanceTester.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60806040523480156200001157600080fd5b5060405162000883380380620008838339818101604052810190620000379190620001e3565b80600090816200004891906200047f565b505062000566565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620000b9826200006e565b810181811067ffffffffffffffff82111715620000db57620000da6200007f565b5b80604052505050565b6000620000f062000050565b9050620000fe8282620000ae565b919050565b600067ffffffffffffffff8211156200012157620001206200007f565b5b6200012c826200006e565b9050602081019050919050565b60005b83811015620001595780820151818401526020810190506200013c565b60008484015250505050565b60006200017c620001768462000103565b620000e4565b9050828152602081018484840111156200019b576200019a62000069565b5b620001a884828562000139565b509392505050565b600082601f830112620001c857620001c762000064565b5b8151620001da84826020860162000165565b91505092915050565b600060208284031215620001fc57620001fb6200005a565b5b600082015167ffffffffffffffff8111156200021d576200021c6200005f565b5b6200022b84828501620001b0565b91505092915050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200028757607f821691505b6020821081036200029d576200029c6200023f565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620003077fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002c8565b620003138683620002c8565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620003606200035a62000354846200032b565b62000335565b6200032b565b9050919050565b6000819050919050565b6200037c836200033f565b620003946200038b8262000367565b848454620002d5565b825550505050565b600090565b620003ab6200039c565b620003b881848462000371565b505050565b5b81811015620003e057620003d4600082620003a1565b600181019050620003be565b5050565b601f8211156200042f57620003f981620002a3565b6200040484620002b8565b8101602085101562000414578190505b6200042c6200042385620002b8565b830182620003bd565b50505b505050565b600082821c905092915050565b6000620004546000198460080262000434565b1980831691505092915050565b60006200046f838362000441565b9150826002028217905092915050565b6200048a8262000234565b67ffffffffffffffff811115620004a657620004a56200007f565b5b620004b282546200026e565b620004bf828285620003e4565b600060209050601f831160018114620004f75760008415620004e2578287015190505b620004ee858262000461565b8655506200055e565b601f1984166200050786620002a3565b60005b8281101562000531578489015182556001820191506020850194506020810190506200050a565b868310156200055157848901516200054d601f89168262000441565b8355505b6001600288020188555050505b505050505050565b61030d80620005766000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806306fdde0314610046578063242e7fa114610064578063a26388bb14610082575b600080fd5b61004e61008c565b60405161005b9190610255565b60405180910390f35b61006c61011a565b6040516100799190610255565b60405180910390f35b61008a610153565b005b60008054610099906102a6565b80601f01602080910402602001604051908101604052809291908181526020018280546100c5906102a6565b80156101125780601f106100e757610100808354040283529160200191610112565b820191906000526020600020905b8154815290600101906020018083116100f557829003601f168201915b505050505081565b6040518060400160405280601981526020017f5465737420526576657274204572726f72204d6573736167650000000000000081525081565b6040518060400160405280601981526020017f5465737420526576657274204572726f72204d657373616765000000000000008152506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101bc9190610255565b60405180910390fd5b600081519050919050565b600082825260208201905092915050565b60005b838110156101ff5780820151818401526020810190506101e4565b60008484015250505050565b6000601f19601f8301169050919050565b6000610227826101c5565b61023181856101d0565b93506102418185602086016101e1565b61024a8161020b565b840191505092915050565b6000602082019050818103600083015261026f818461021c565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806102be57607f821691505b6020821081036102d1576102d0610277565b5b5091905056fea26469706673582212202704472a01eddebdaeb571ea2f6c0e48fbd140c2982399ccaf6b350827fdfc4064736f6c63430008150033
60806040523480156200001157600080fd5b5060405162000ad638038062000ad68339818101604052810190620000379190620001e3565b80600090816200004891906200047f565b505062000566565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620000b9826200006e565b810181811067ffffffffffffffff82111715620000db57620000da6200007f565b5b80604052505050565b6000620000f062000050565b9050620000fe8282620000ae565b919050565b600067ffffffffffffffff8211156200012157620001206200007f565b5b6200012c826200006e565b9050602081019050919050565b60005b83811015620001595780820151818401526020810190506200013c565b60008484015250505050565b60006200017c620001768462000103565b620000e4565b9050828152602081018484840111156200019b576200019a62000069565b5b620001a884828562000139565b509392505050565b600082601f830112620001c857620001c762000064565b5b8151620001da84826020860162000165565b91505092915050565b600060208284031215620001fc57620001fb6200005a565b5b600082015167ffffffffffffffff8111156200021d576200021c6200005f565b5b6200022b84828501620001b0565b91505092915050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200028757607f821691505b6020821081036200029d576200029c6200023f565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620003077fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002c8565b620003138683620002c8565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620003606200035a62000354846200032b565b62000335565b6200032b565b9050919050565b6000819050919050565b6200037c836200033f565b620003946200038b8262000367565b848454620002d5565b825550505050565b600090565b620003ab6200039c565b620003b881848462000371565b505050565b5b81811015620003e057620003d4600082620003a1565b600181019050620003be565b5050565b601f8211156200042f57620003f981620002a3565b6200040484620002b8565b8101602085101562000414578190505b6200042c6200042385620002b8565b830182620003bd565b50505b505050565b600082821c905092915050565b6000620004546000198460080262000434565b1980831691505092915050565b60006200046f838362000441565b9150826002028217905092915050565b6200048a8262000234565b67ffffffffffffffff811115620004a657620004a56200007f565b5b620004b282546200026e565b620004bf828285620003e4565b600060209050601f831160018114620004f75760008415620004e2578287015190505b620004ee858262000461565b8655506200055e565b601f1984166200050786620002a3565b60005b8281101562000531578489015182556001820191506020850194506020810190506200050a565b868310156200055157848901516200054d601f89168262000441565b8355505b6001600288020188555050505b505050505050565b61056080620005766000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306fdde031461005c578063242e7fa11461007a57806327e235e314610098578063a26388bb146100c8578063b6b55f25146100d2575b600080fd5b6100646100ee565b6040516100719190610328565b60405180910390f35b61008261017c565b60405161008f9190610328565b60405180910390f35b6100b260048036038101906100ad91906103ad565b6101b5565b6040516100bf91906103f3565b60405180910390f35b6100d06101cd565b005b6100ec60048036038101906100e7919061043a565b61023f565b005b600080546100fb90610496565b80601f016020809104026020016040519081016040528092919081815260200182805461012790610496565b80156101745780601f1061014957610100808354040283529160200191610174565b820191906000526020600020905b81548152906001019060200180831161015757829003601f168201915b505050505081565b6040518060400160405280601981526020017f5465737420526576657274204572726f72204d6573736167650000000000000081525081565b60016020528060005260406000206000915090505481565b6040518060400160405280601981526020017f5465737420526576657274204572726f72204d657373616765000000000000008152506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102369190610328565b60405180910390fd5b80600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461028e91906104f6565b9250508190555050565b600081519050919050565b600082825260208201905092915050565b60005b838110156102d25780820151818401526020810190506102b7565b60008484015250505050565b6000601f19601f8301169050919050565b60006102fa82610298565b61030481856102a3565b93506103148185602086016102b4565b61031d816102de565b840191505092915050565b6000602082019050818103600083015261034281846102ef565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061037a8261034f565b9050919050565b61038a8161036f565b811461039557600080fd5b50565b6000813590506103a781610381565b92915050565b6000602082840312156103c3576103c261034a565b5b60006103d184828501610398565b91505092915050565b6000819050919050565b6103ed816103da565b82525050565b600060208201905061040860008301846103e4565b92915050565b610417816103da565b811461042257600080fd5b50565b6000813590506104348161040e565b92915050565b6000602082840312156104505761044f61034a565b5b600061045e84828501610425565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806104ae57607f821691505b6020821081036104c1576104c0610467565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610501826103da565b915061050c836103da565b9250828201905080821115610524576105236104c7565b5b9291505056fea264697066735822122097c56af386cdc27f1819acc9acc5fd56d14a42aeb926a842f69be51b4dc250ad64736f6c63430008150033
Loading

0 comments on commit 73b3e0e

Please sign in to comment.