Skip to content

Commit

Permalink
make the call trace test work (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Poytr1 committed Nov 1, 2023
1 parent 5a68daa commit 77053b2
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
{
"pc": 0,
"module_id": "",
"func_name": "create_account",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"outputs": [],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "create_account",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"outputs": [
"(container 600003fbec88: [Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])"
],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "create_account_unchecked",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"outputs": [
"(container 600003fbec88: [Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])"
],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::guid",
"func_name": "create",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)",
"(&container 600003fd1bd8)[3]"
],
"outputs": [
"(container 600003fd1b78: [(container 600003fd1848: [U64(0), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::event",
"func_name": "new_event_handle",
"inputs": [
"(container 600003fd1a28: [(container 600003fd1ab8: [U64(0), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"outputs": [
"(container 600003fd1f68: [U64(0), (container 600003fd18d8: [(container 600003fd1848: [U64(0), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])])"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::guid",
"func_name": "create",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)",
"(&container 600003fd1bd8)[3]"
],
"outputs": [
"(container 600003fd1e48: [(container 600003fd1ea8: [U64(1), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::event",
"func_name": "new_event_handle",
"inputs": [
"(container 600003fd18d8: [(container 600003fd1ab8: [U64(1), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"outputs": [
"(container 600003fd1d88: [U64(0), (container 600003fd1de8: [(container 600003fd1ea8: [U64(1), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])])"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::option",
"func_name": "none",
"inputs": [],
"outputs": [
"(container 600003fbf978: [(container 600003fbf6d8: [])])"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::option",
"func_name": "none",
"inputs": [],
"outputs": [
"(container 600003fbc978: [(container 600003fbc948: [])])"
],
"type_args": [],
"sub_traces": []
}
]
}
]
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::coin",
"func_name": "register",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::signer",
"func_name": "address_of",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::coin",
"func_name": "is_account_registered",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"outputs": [
"false"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "register_coin",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"outputs": [],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::event",
"func_name": "emit_event",
"inputs": [
"(&container 600003fd1b78)",
"(container 600003fbfb88: [(container 600003fbf588: [Address(1), (container 600003fbee38: [97, 112, 116, 111, 115, 95, 99, 111, 105, 110]), (container 600003fbe8f8: [65, 112, 116, 111, 115, 67, 111, 105, 110])])])"
],
"outputs": [],
"type_args": [],
"sub_traces": []
}
]
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "new_event_handle",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"(container 600003fbe808: [U64(0), (container 600003fbeb68: [(container 600003fbeb38: [U64(2), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])])"
],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "create_guid",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"(container 600003fbea48: [(container 600003fbee38: [U64(2), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::signer",
"func_name": "address_of",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::guid",
"func_name": "create",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)",
"(&container 600003fbc948)[2]"
],
"outputs": [
"(container 600003fbe808: [(container 600003fbeef8: [U64(2), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"type_args": [],
"sub_traces": []
}
]
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::event",
"func_name": "new_event_handle",
"inputs": [
"(container 600003fbeb68: [(container 600003fbeb38: [U64(2), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"outputs": [
"(container 600003fbe808: [U64(0), (container 600003fbee38: [(container 600003fbea48: [U64(2), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])])"
],
"type_args": [],
"sub_traces": []
}
]
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "new_event_handle",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"(container 600003fbec28: [U64(0), (container 600003fbeb68: [(container 600003fbea48: [U64(3), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])])"
],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::account",
"func_name": "create_guid",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"(container 600003fbeef8: [(container 600003fbe508: [U64(3), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"type_args": [],
"sub_traces": [
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::signer",
"func_name": "address_of",
"inputs": [
"(&container 600003fd1f98)"
],
"outputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)"
],
"type_args": [],
"sub_traces": []
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::guid",
"func_name": "create",
"inputs": [
"Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)",
"(&container 600003fbc948)[2]"
],
"outputs": [
"(container 600003fbec28: [(container 600003fbeb98: [U64(3), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"type_args": [],
"sub_traces": []
}
]
},
{
"pc": 0,
"module_id": "0000000000000000000000000000000000000000000000000000000000000001::event",
"func_name": "new_event_handle",
"inputs": [
"(container 600003fbeb68: [(container 600003fbea48: [U64(3), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])"
],
"outputs": [
"(container 600003fbec28: [U64(0), (container 600003fbe508: [(container 600003fbeef8: [U64(3), Address(34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf)])])])"
],
"type_args": [],
"sub_traces": []
}
]
}
]
}
]
}
32 changes: 32 additions & 0 deletions api/src/tests/call_trace_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use aptos_api_test_context::{assert_json, current_function_name, pretty, TestContext};
use super::new_test_context;

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_get_call_trace_by_hash() {
let mut context = new_test_context(current_function_name!());
let account = context.gen_account();
let txn = context.create_user_account(&account).await;
context.commit_block(&vec![txn.clone()]).await;

let txns = context.get("/transactions?start=2&limit=1").await;
assert_eq!(1, txns.as_array().unwrap().len());

let resp = context
.get(&format!(
"/transactions/by_hash/{}",
txns[0]["hash"].as_str().unwrap()
))
.await;
assert_json(resp, txns[0].clone());

let call_trace_resp = context.
get(&format!(
"/call_trace/by_hash/{}",
txns[0]["hash"].as_str().unwrap()
))
.await;
context.check_golden_output(call_trace_resp);
}
30 changes: 0 additions & 30 deletions api/src/tests/call_trace_tests.rs

This file was deleted.

2 changes: 1 addition & 1 deletion api/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod string_resource_test;
mod transaction_vector_test;
mod transactions_test;
mod view_function;
mod call_trace_tests;
mod call_trace_test;

use aptos_api_test_context::{new_test_context as super_new_test_context, TestContext};
use aptos_config::config::NodeConfig;
Expand Down
Loading

0 comments on commit 77053b2

Please sign in to comment.