-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a feature to generate testing transactions (#518)
* Add a feature to generat testing transactions that can be used for processor testing. This enables us to skip creating a pr whenever there is new transaction to test with. * lint
- Loading branch information
Showing
12 changed files
with
2,396 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "testing-transactions" | ||
version = "0.1.0" | ||
|
||
# Workspace inherited keys | ||
authors = { workspace = true } | ||
edition = { workspace = true } | ||
homepage = { workspace = true } | ||
license = { workspace = true } | ||
publish = { workspace = true } | ||
repository = { workspace = true } | ||
rust-version = { workspace = true } | ||
|
||
[dependencies] | ||
aptos-protos ={ workspace = true } | ||
serde_json = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// build.rs | ||
use std::{env, fs, path::Path}; | ||
|
||
fn main() { | ||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
println!("OUT_DIR: {:?}", out_dir); | ||
let dest_path = Path::new(&out_dir).join("generate_transactions.rs"); | ||
let mut transactions_code = String::new(); | ||
let json_dir = Path::new("json_transactions"); | ||
for entry in fs::read_dir(json_dir).unwrap() { | ||
let entry = entry.unwrap(); | ||
let path = entry.path(); | ||
if path.extension().and_then(|s| s.to_str()) == Some("json") { | ||
let file_name = path.file_stem().unwrap().to_str().unwrap(); | ||
let const_name = file_name.to_uppercase().replace('-', "_"); | ||
|
||
let json_code = format!( | ||
r#" | ||
pub const {const_name}: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/json_transactions/{file_name}.json")); | ||
"#, | ||
const_name = const_name, | ||
file_name = file_name, | ||
); | ||
transactions_code.push_str(&json_code); | ||
} | ||
} | ||
fs::write(dest_path, transactions_code).unwrap(); | ||
} |
291 changes: 291 additions & 0 deletions
291
rust/testing-transactions/json_transactions/account_a_get_funded_from_faucet.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,291 @@ | ||
{ | ||
"timestamp": { | ||
"seconds": "1722246280", | ||
"nanos": 999230000 | ||
}, | ||
"version": "5524190992", | ||
"info": { | ||
"hash": "9u1tiBJTfUpcFsoKtJKfqpb4hWbz6Zq0+l/kmJrvmRQ=", | ||
"stateChangeHash": "dSvWbb9A1Njayi8522XP4CRnJEaIXcgPL9hwMuLC2Ls=", | ||
"eventRootHash": "iX1ELvz8fXL4p6APhREH/kP5KQq4Fw/T3Isrcc3W9+Y=", | ||
"gasUsed": "1001", | ||
"success": true, | ||
"vmStatus": "Executed successfully", | ||
"accumulatorRootHash": "zxr63s4RL8yAwM+AZduTy0j2diWNi328bJKtCD+fekU=", | ||
"changes": [ | ||
{ | ||
"type": "TYPE_WRITE_RESOURCE", | ||
"writeResource": { | ||
"address": "0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb", | ||
"stateKeyHash": "NO4exGs6RLXsCA6pGBWJ3i5FxUR9urylYXvjxzGBVE4=", | ||
"type": { | ||
"address": "0x1", | ||
"module": "coin", | ||
"name": "CoinStore", | ||
"genericTypeParams": [ | ||
{ | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "aptos_coin", | ||
"name": "AptosCoin" | ||
} | ||
} | ||
] | ||
}, | ||
"typeStr": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", | ||
"data": "{\"coin\":{\"value\":\"225379021750\"},\"deposit_events\":{\"counter\":\"1345637\",\"guid\":{\"id\":{\"addr\":\"0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"1345624\",\"guid\":{\"id\":{\"addr\":\"0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb\",\"creation_num\":\"3\"}}}}" | ||
} | ||
}, | ||
{ | ||
"type": "TYPE_WRITE_RESOURCE", | ||
"writeResource": { | ||
"address": "0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb", | ||
"stateKeyHash": "u34zRmqkZYLKVzYCOBOMbWPtN8szyG02m+Of/dmxFUw=", | ||
"type": { | ||
"address": "0x1", | ||
"module": "account", | ||
"name": "Account" | ||
}, | ||
"typeStr": "0x1::account::Account", | ||
"data": "{\"authentication_key\":\"0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb\",\"coin_register_events\":{\"counter\":\"1\",\"guid\":{\"id\":{\"addr\":\"0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb\",\"creation_num\":\"0\"}}},\"guid_creation_num\":\"4\",\"key_rotation_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb\",\"creation_num\":\"1\"}}},\"rotation_capability_offer\":{\"for\":{\"vec\":[]}},\"sequence_number\":\"1345635\",\"signer_capability_offer\":{\"for\":{\"vec\":[]}}}" | ||
} | ||
}, | ||
{ | ||
"type": "TYPE_WRITE_RESOURCE", | ||
"writeResource": { | ||
"address": "0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2", | ||
"stateKeyHash": "iSj4XNRWy0NEu971y15qfgX60oXWnPW/2MUkQGCUBrc=", | ||
"type": { | ||
"address": "0x1", | ||
"module": "coin", | ||
"name": "CoinStore", | ||
"genericTypeParams": [ | ||
{ | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "aptos_coin", | ||
"name": "AptosCoin" | ||
} | ||
} | ||
] | ||
}, | ||
"typeStr": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", | ||
"data": "{\"coin\":{\"value\":\"100000000\"},\"deposit_events\":{\"counter\":\"1\",\"guid\":{\"id\":{\"addr\":\"0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2\",\"creation_num\":\"3\"}}}}" | ||
} | ||
}, | ||
{ | ||
"type": "TYPE_WRITE_RESOURCE", | ||
"writeResource": { | ||
"address": "0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2", | ||
"stateKeyHash": "WItcVnHUvRZJFz30CYBH/6JKkFJO2SsICXYp1nads8U=", | ||
"type": { | ||
"address": "0x1", | ||
"module": "account", | ||
"name": "Account" | ||
}, | ||
"typeStr": "0x1::account::Account", | ||
"data": "{\"authentication_key\":\"0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2\",\"coin_register_events\":{\"counter\":\"1\",\"guid\":{\"id\":{\"addr\":\"0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2\",\"creation_num\":\"0\"}}},\"guid_creation_num\":\"4\",\"key_rotation_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2\",\"creation_num\":\"1\"}}},\"rotation_capability_offer\":{\"for\":{\"vec\":[]}},\"sequence_number\":\"0\",\"signer_capability_offer\":{\"for\":{\"vec\":[]}}}" | ||
} | ||
}, | ||
{ | ||
"type": "TYPE_WRITE_TABLE_ITEM", | ||
"writeTableItem": { | ||
"stateKeyHash": "bkso1A+YoQamUWNTCSTA3LQME0nTqpFdEItNbPwd2xk=", | ||
"handle": "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca", | ||
"key": "0x0619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935", | ||
"data": { | ||
"key": "\"0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935\"", | ||
"keyType": "address", | ||
"value": "\"29159041932810165790\"", | ||
"valueType": "u128" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"epoch": "16653", | ||
"blockHeight": "322562789", | ||
"type": "TRANSACTION_TYPE_USER", | ||
"sizeInfo": { | ||
"transactionBytes": 475, | ||
"eventSizeInfo": [ | ||
{ | ||
"typeTagBytes": 52, | ||
"totalBytes": 108 | ||
}, | ||
{ | ||
"typeTagBytes": 60, | ||
"totalBytes": 161 | ||
}, | ||
{ | ||
"typeTagBytes": 53, | ||
"totalBytes": 109 | ||
}, | ||
{ | ||
"typeTagBytes": 52, | ||
"totalBytes": 108 | ||
}, | ||
{ | ||
"typeTagBytes": 63, | ||
"totalBytes": 103 | ||
} | ||
], | ||
"writeOpSizeInfo": [ | ||
{ | ||
"keyBytes": 138, | ||
"valueBytes": 105 | ||
}, | ||
{ | ||
"keyBytes": 84, | ||
"valueBytes": 147 | ||
}, | ||
{ | ||
"keyBytes": 138, | ||
"valueBytes": 105 | ||
}, | ||
{ | ||
"keyBytes": 84, | ||
"valueBytes": 147 | ||
}, | ||
{ | ||
"keyBytes": 66, | ||
"valueBytes": 16 | ||
} | ||
] | ||
}, | ||
"user": { | ||
"request": { | ||
"sender": "0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb", | ||
"sequenceNumber": "1345634", | ||
"maxGasAmount": "500000", | ||
"gasUnitPrice": "100", | ||
"expirationTimestampSecs": { | ||
"seconds": "1722246295" | ||
}, | ||
"payload": { | ||
"type": "TYPE_SCRIPT_PAYLOAD", | ||
"scriptPayload": { | ||
"code": { | ||
"bytecode": "oRzrCwUAAAAIAQAIAggEAwwVBCECBSMQBzNQCIMBIAajARQAAAABAAIAAwEFCAADBAMBAAIGAQUBAAEHAAIAAAgAAgABBAMGDAUDAQUAAQYMAQgAAQMNYXB0b3NfYWNjb3VudAphcHRvc19jb2luBGNvaW4Gc2lnbmVyCmFkZHJlc3Nfb2YJQXB0b3NDb2luB2JhbGFuY2UEbWludAh0cmFuc2ZlcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAwighgEAAAAAAAMI//////////8AAAEXCgARAAwDCgM4AAcBCgIXBwAXIwQSCgALAwoCBwAWEQILAAsBCwIRAwI=", | ||
"abi": { | ||
"name": "main", | ||
"visibility": "VISIBILITY_PUBLIC", | ||
"isEntry": true, | ||
"params": [ | ||
{ | ||
"type": "MOVE_TYPES_REFERENCE", | ||
"reference": { | ||
"to": { | ||
"type": "MOVE_TYPES_SIGNER" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "MOVE_TYPES_ADDRESS" | ||
}, | ||
{ | ||
"type": "MOVE_TYPES_U64" | ||
} | ||
] | ||
} | ||
}, | ||
"arguments": [ | ||
"\"0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2\"", | ||
"\"100000000\"" | ||
] | ||
} | ||
}, | ||
"signature": { | ||
"type": "TYPE_ED25519", | ||
"ed25519": { | ||
"publicKey": "UFdI6CaGx2yWzNCGgupSjfWTm9vbCnlDGdJkKxaVv5c=", | ||
"signature": "CsqIVmJ7mLaoGk4qwyQ5DqfUpdX0KFdKVUy6uLFTcblcGIhtX93j2JuMcLFI42be/3aNTCw25aJKT16l3HXeBg==" | ||
} | ||
} | ||
}, | ||
"events": [ | ||
{ | ||
"key": { | ||
"creationNumber": "2", | ||
"accountAddress": "0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb" | ||
}, | ||
"sequenceNumber": "1345636", | ||
"type": { | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "coin", | ||
"name": "DepositEvent" | ||
} | ||
}, | ||
"typeStr": "0x1::coin::DepositEvent", | ||
"data": "{\"amount\":\"100100000\"}" | ||
}, | ||
{ | ||
"key": { | ||
"accountAddress": "0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2" | ||
}, | ||
"type": { | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "account", | ||
"name": "CoinRegisterEvent" | ||
} | ||
}, | ||
"typeStr": "0x1::account::CoinRegisterEvent", | ||
"data": "{\"type_info\":{\"account_address\":\"0x1\",\"module_name\":\"0x6170746f735f636f696e\",\"struct_name\":\"0x4170746f73436f696e\"}}" | ||
}, | ||
{ | ||
"key": { | ||
"creationNumber": "3", | ||
"accountAddress": "0x832fd5e456b7f43c4ef27978766ee5242a8a393d10ef5bf662d40f774a6f2deb" | ||
}, | ||
"sequenceNumber": "1345623", | ||
"type": { | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "coin", | ||
"name": "WithdrawEvent" | ||
} | ||
}, | ||
"typeStr": "0x1::coin::WithdrawEvent", | ||
"data": "{\"amount\":\"100000000\"}" | ||
}, | ||
{ | ||
"key": { | ||
"creationNumber": "2", | ||
"accountAddress": "0xeea01e0c163fe390e30afd0e6ff88a3535a2d78b4cbbcc8f9bf3848b5a8fbcf2" | ||
}, | ||
"type": { | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "coin", | ||
"name": "DepositEvent" | ||
} | ||
}, | ||
"typeStr": "0x1::coin::DepositEvent", | ||
"data": "{\"amount\":\"100000000\"}" | ||
}, | ||
{ | ||
"key": { | ||
"accountAddress": "0x0" | ||
}, | ||
"type": { | ||
"type": "MOVE_TYPES_STRUCT", | ||
"struct": { | ||
"address": "0x1", | ||
"module": "transaction_fee", | ||
"name": "FeeStatement" | ||
} | ||
}, | ||
"typeStr": "0x1::transaction_fee::FeeStatement", | ||
"data": "{\"execution_gas_units\":\"6\",\"io_gas_units\":\"7\",\"storage_fee_octas\":\"98800\",\"storage_fee_refund_octas\":\"0\",\"total_charge_gas_units\":\"1001\"}" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.