From 509c1162de28478909fc121d0e69ee118b49fe0b Mon Sep 17 00:00:00 2001 From: Sean Derman Yang <38265412+dermanyang@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:01:35 -0800 Subject: [PATCH] Create Diff Tests for UserTransactionsProcessor (#600) --- rust/Cargo.lock | 8 +- rust/Cargo.toml | 2 +- .../test_multi_ed25519/signatures.json | 74 +++++++ .../test_multi_ed25519/user_transactions.json | 15 ++ .../signatures.json | 17 ++ .../user_transactions.json | 15 ++ .../test_single_ed25519/signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../test_single_key_ed25519/signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../test_single_key_secp/signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../test_single_sender_secp/signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../signatures.json | 15 ++ .../user_transactions.json | 15 ++ .../user_transaction_processor.rs | 1 + rust/integration-tests/src/sdk_tests/mod.rs | 3 + .../user_transaction_processor_tests.rs | 190 ++++++++++++++++++ 23 files changed, 530 insertions(+), 5 deletions(-) create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/user_transactions.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/signatures.json create mode 100644 rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/user_transactions.json create mode 100644 rust/integration-tests/src/sdk_tests/user_transaction_processor_tests.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 51f288ca2..0fe5a6e47 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "aptos-indexer-test-transactions" version = "1.0.0" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=4b67e5d816d554b5af4b2c130b283d00799268b7#4b67e5d816d554b5af4b2c130b283d00799268b7" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=cf85a5d78c6b6da6499201f583f5fef6a434071e#cf85a5d78c6b6da6499201f583f5fef6a434071e" dependencies = [ - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=4b67e5d816d554b5af4b2c130b283d00799268b7)", + "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=cf85a5d78c6b6da6499201f583f5fef6a434071e)", "serde_json", ] @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "aptos-protos" version = "1.3.1" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=4b67e5d816d554b5af4b2c130b283d00799268b7#4b67e5d816d554b5af4b2c130b283d00799268b7" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb#5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" dependencies = [ "futures-core", "pbjson", @@ -309,7 +309,7 @@ dependencies = [ [[package]] name = "aptos-protos" version = "1.3.1" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb#5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=cf85a5d78c6b6da6499201f583f5fef6a434071e#cf85a5d78c6b6da6499201f583f5fef6a434071e" dependencies = [ "futures-core", "pbjson", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 40095ec30..2967ddac1 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -34,7 +34,7 @@ aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-index aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" } aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" } aptos-system-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "202bdccff2b2d333a385ae86a4fcf23e89da9f62" } -aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "4b67e5d816d554b5af4b2c130b283d00799268b7" } +aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "cf85a5d78c6b6da6499201f583f5fef6a434071e" } aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" } async-trait = "0.1.53" backtrace = "0.3.58" diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/signatures.json new file mode 100644 index 000000000..9ff67f14d --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/signatures.json @@ -0,0 +1,74 @@ +[ + { + "transaction_version": 2175935, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 1071136, + "signer": "0xaa90e0d9d16b63ba4a289fb0dc8d1b454058b21c9b5c76864f825d5c1f32582e", + "is_sender_primary": true, + "type_": "multi_ed25519_signature", + "public_key": "0x79c65acf6c2d39be49362a12438d09ddd8a09ac4ef2bf16c6ac12190808d4668", + "signature": "0x94fb6cc53f5a51a6d30902d74a2e175b7ae7a4deb991303c33e1cba3b543adcc06643f8d14d47bc00f1aeadbae1e0d58623ee4c033d300ba2314da3fcfd4cc0f", + "threshold": 3, + "public_key_indices": [ + 0, + 1, + 2, + 3 + ] + }, + { + "transaction_version": 2175935, + "multi_agent_index": 0, + "multi_sig_index": 1, + "transaction_block_height": 1071136, + "signer": "0xaa90e0d9d16b63ba4a289fb0dc8d1b454058b21c9b5c76864f825d5c1f32582e", + "is_sender_primary": true, + "type_": "multi_ed25519_signature", + "public_key": "0xf8609e30dcea4a3930da12c8ff7341ae4379930484c3bbc280085ee6a1455c50", + "signature": "0xe03eb15ea0dab549e34ae1d979f6de2c63ce4f64f54bd8c2283598595b0e755815d516aeb37d00128ce41b15dd219131aaaeaa1946ba44679f76ebbd9be7730b", + "threshold": 3, + "public_key_indices": [ + 0, + 1, + 2, + 3 + ] + }, + { + "transaction_version": 2175935, + "multi_agent_index": 0, + "multi_sig_index": 2, + "transaction_block_height": 1071136, + "signer": "0xaa90e0d9d16b63ba4a289fb0dc8d1b454058b21c9b5c76864f825d5c1f32582e", + "is_sender_primary": true, + "type_": "multi_ed25519_signature", + "public_key": "0x745a05201579729817f02983fd420d6072721fb87a73fbd31d7c6202c8459ae5", + "signature": "0x8ae38f8d9408ea62b33d34e8b8f9a120c36b2fb1f00c40e090810109d17041c7fb1e76be874f023a50473e7e22d0a39c65f97d9e23e8387560c9e4765470be0e", + "threshold": 3, + "public_key_indices": [ + 0, + 1, + 2, + 3 + ] + }, + { + "transaction_version": 2175935, + "multi_agent_index": 0, + "multi_sig_index": 3, + "transaction_block_height": 1071136, + "signer": "0xaa90e0d9d16b63ba4a289fb0dc8d1b454058b21c9b5c76864f825d5c1f32582e", + "is_sender_primary": true, + "type_": "multi_ed25519_signature", + "public_key": "0xa11beec494a2ae664e1b47e331d0c7c289a786ca73afcf0cfef52814c7210a2c", + "signature": "0x9882cf9628b492d713c154baa13c72aa1c94c93ed8fcf102090a6afbd078ccd6d399d4939fd39717532cc53caee0bed75614b636eddd8589c194da3b40371005", + "threshold": 3, + "public_key_indices": [ + 0, + 1, + 2, + 3 + ] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/user_transactions.json new file mode 100644 index 000000000..547e55998 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_ed25519/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 2175935, + "block_height": 1071136, + "parent_signature_type": "multi_ed25519_signature", + "sender": "0xaa90e0d9d16b63ba4a289fb0dc8d1b454058b21c9b5c76864f825d5c1f32582e", + "sequence_number": 0, + "max_gas_amount": "10000", + "expiration_timestamp_secs": "2022-10-18T23:19:15", + "gas_unit_price": "100", + "timestamp": "2022-10-18T23:10:04.331016", + "entry_function_id_str": "0xa3f6a53c57395401ce64f09a188e2259dc9b156387e76c88a7a80a8fe5254476::momentum_safe::register", + "epoch": 75 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/signatures.json new file mode 100644 index 000000000..3d0915458 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/signatures.json @@ -0,0 +1,17 @@ +[ + { + "transaction_version": 1803170308, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 239859401, + "signer": "0xcd132e9b9827da619824510675148bf402333ab539b3ae0ce170ceeee2a37902", + "is_sender_primary": true, + "type_": "multi_key_keyless_signature", + "public_key": "0x1b68747470733a2f2f6163636f756e74732e676f6f676c652e636f6d20a3d1b2af18bbb379a4721dcaa557b8c2bde7a95e08108f83e9e37a23622a3f2a", + "signature": "0x000005b2bb1b3d5069b143ad2dcd9b0be72b432ef21fba222821fde9dd1b0fa5309681c60175463cff9ae0eb879d0b06dcfb1749facb0a6d2589701ca4804d96972ffcd23279b491735187f7e861003835d70bf473bc84de4d7cfcdef71998054e9b847c8c68113060ead4788ea97bbc0fd3cff3974938207c787f15a78c4e16c00c80969800000000000000010040011f33b0af6221f0e86d007f711971f1e3e6abc34f0ac00d9b992499c18020fdb7807173b533efdd38d0686ad3de988ee1ee5957dbaeddf21e2bbf9b3a21ed024c7b22616c67223a225253323536222c226b6964223a2261353066366537306566346235343861356664393134326565636431666238663534646365396565222c22747970223a224a5754227dd3622667000000000020fe09cb6421813f17db4d367849f7581cf7d218d071de82232f92ecf19ba72d740040e8f0777d3e0c8c7e4a50ace0dbf9d0d5b6fc7b0a2300792bd36a7690658abf83c86e1fc850b6402af7e204df74bebfc5d08a8c7841bff5089ffc39b6b0227b05", + "threshold": 1, + "public_key_indices": [ + 1 + ] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/user_transactions.json new file mode 100644 index 000000000..72ce0bca0 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_multi_key_keyless_signature/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 1803170308, + "block_height": 239859401, + "parent_signature_type": "fee_payer_signature", + "sender": "0xcd132e9b9827da619824510675148bf402333ab539b3ae0ce170ceeee2a37902", + "sequence_number": 0, + "max_gas_amount": "10010", + "expiration_timestamp_secs": "2024-10-16T17:07:41", + "gas_unit_price": "100", + "timestamp": "2024-10-16T17:07:21.987832", + "entry_function_id_str": "0x1::aptos_account::transfer", + "epoch": 8870 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/signatures.json new file mode 100644 index 000000000..89899f813 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 685, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 343, + "signer": "0xfda457fe15be3102b748877e674b4b076b06e4c13e8eaf4d817b5baa77889bf9", + "is_sender_primary": true, + "type_": "ed25519_signature", + "public_key": "0x52c68c2ebe3fde3e479d7b04f486745245984daee3411ac1218cf123348603fd", + "signature": "0x37b89d3d3d6e68e66c4f72be6228890690d2a9c39e0a75aed12b122400ab5812f1170ac14151ad6ce8f75dda7dd29f8c98c5f2b176bb23fc0af574d10f713d0b", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/user_transactions.json new file mode 100644 index 000000000..094505ecc --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_ed25519/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 685, + "block_height": 343, + "parent_signature_type": "ed25519_signature", + "sender": "0xfda457fe15be3102b748877e674b4b076b06e4c13e8eaf4d817b5baa77889bf9", + "sequence_number": 0, + "max_gas_amount": "861", + "expiration_timestamp_secs": "2022-10-12T21:26:49", + "gas_unit_price": "100", + "timestamp": "2022-10-12T21:26:20.299882", + "entry_function_id_str": "0x1::stake::update_network_and_fullnode_addresses", + "epoch": 2 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/signatures.json new file mode 100644 index 000000000..e96834f12 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 464961735, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 149367565, + "signer": "0x21cca3a6dcf46ec6888067f7955d857d4991cd49359c2f1bf35f6d242a0f5f13", + "is_sender_primary": true, + "type_": "single_sender_ed25519_signature", + "public_key": "0x7b2fd9c7c0c7b043c13360bc35b119de5774d2ed4078429ea0f224eff1e561ca", + "signature": "0x2143fcb53d2da0d2f4c053a819ae2055c007c6902a1863fc7da72a50933feb1a630d3ae043e6713a29861fcb5071b04b536dbbf52241503d7616ec8d21b4a505", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/user_transactions.json new file mode 100644 index 000000000..804af7f0b --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_ed25519/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 464961735, + "block_height": 149367565, + "parent_signature_type": "single_key_signature", + "sender": "0x21cca3a6dcf46ec6888067f7955d857d4991cd49359c2f1bf35f6d242a0f5f13", + "sequence_number": 0, + "max_gas_amount": "200000", + "expiration_timestamp_secs": "2024-02-23T22:22:10", + "gas_unit_price": "100", + "timestamp": "2024-02-23T22:21:53.482262", + "entry_function_id_str": "0x1::coin::transfer", + "epoch": 6013 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/signatures.json new file mode 100644 index 000000000..6fdecd348 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 407418623, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 134705653, + "signer": "0x1a2a80523dd7235cc88997eb6382995455148cda0479a15242f9056ae08aec41", + "is_sender_primary": true, + "type_": "single_sender_secp256k1_ecdsa_signature", + "public_key": "0x045f3197545fabcdffe43d95af03c0aaa8a56778e508e3519dceb727bc7f0752d3b82c131d3ba44006e44314384537f43a1f8aa9e92a7acfbbadb3192b2d9ded7d", + "signature": "0xa98656f8f1f1c32537df4bf00df9353daaf9bb546e30a8875900cec598fe8a7f6ed0aecd0e0d4db34b3ccfbedd7a731d63d1292f668d46d51a5cb8690c79269a", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/user_transactions.json new file mode 100644 index 000000000..6b0ae973e --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_key_secp/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 407418623, + "block_height": 134705653, + "parent_signature_type": "single_key_signature", + "sender": "0x1a2a80523dd7235cc88997eb6382995455148cda0479a15242f9056ae08aec41", + "sequence_number": 0, + "max_gas_amount": "8", + "expiration_timestamp_secs": "2024-01-16T09:35:27", + "gas_unit_price": "100", + "timestamp": "2024-01-16T09:35:08.981259", + "entry_function_id_str": "0x1::coin::transfer", + "epoch": 5547 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/signatures.json new file mode 100644 index 000000000..532d7742a --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 590098441, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 177673906, + "signer": "0x5a2de9a743dfe5b4dd76527e6c2091f11819091d7ba1efb2fb6d57c0b83b759b", + "is_sender_primary": true, + "type_": "single_sender_ed25519_signature", + "public_key": "0xf3dd681d0ff72a7b343de6ed8f9b0d34ce6267e5ddc9a95caf21257014d98a63", + "signature": "0xbf7d74ef39a6c8cbbaf662bca8a16afc0b716f1c7e0d170ed9e400fb7333679906ead9cd7d46a3c2d5d1e6b90780bea37376f3041d1c511da8097d66b2e2c908", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/user_transactions.json new file mode 100644 index 000000000..74f3b2381 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_ed25519/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 590098441, + "block_height": 177673906, + "parent_signature_type": "single_key_signature", + "sender": "0x5a2de9a743dfe5b4dd76527e6c2091f11819091d7ba1efb2fb6d57c0b83b759b", + "sequence_number": 0, + "max_gas_amount": "200000", + "expiration_timestamp_secs": "2024-05-09T01:19:19", + "gas_unit_price": "100", + "timestamp": "2024-05-09T01:18:59.975711", + "entry_function_id_str": "0x1::aptos_account::transfer_coins", + "epoch": 6924 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/signatures.json new file mode 100644 index 000000000..0b2974d13 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 976087151, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 189192230, + "signer": "0x2702d121810b0dd82da7fe72abc0972cb087cd8f37b55367a8fb0b2faead0763", + "is_sender_primary": true, + "type_": "single_sender_keyless_signature", + "public_key": "0x1b68747470733a2f2f6163636f756e74732e676f6f676c652e636f6d20df280a94dd75e9e243f99287dc58768713a1aa7ed79f5a55b549bfafb606aa26", + "signature": "0x0000835679c3656bfb12bb2037f1347d73fb7ead3cf44781029c30bf4e7020e8f583a08efcf8a75d2d7c61ce0a653a7d25f481b18f593bc27a70b660b96f1760d4196495c80c8c37733824f659eb09cab4071f5c0a74a8e3f6ad26b3e7f5e9f9ce9dca02f27d6374037d2509a593fc298a3aebe72eb6c11725d4872a8c5ba1abeb218096980000000000000001004067be20b1bd8ea5b3fc3a5acc52835d72435a3bd5203a2908d21355c0b113daf4d3a3b5001eecbbf056ae0b47beae3af6b29c9cb532449d1191db631474923d024c7b22616c67223a225253323536222c226b6964223a2236373464626261386661656536396163616531626331626531393034353336373866343732383033222c22747970223a224a5754227df0897966000000000020cba966518a65b303bc2101b0f493630aba3aa2ce1d41c7bc794126a599ace09d0040a2a156c6d2c0dd49499b7fbdd5eb9b9ba35dffca2ac764a46ec2f886f66d2015c8736c9468ecbd4c5adc8e83e3dd2968358d0194023fa1cf8ae43fd3ba09ff0b", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/user_transactions.json new file mode 100644 index 000000000..426a9c1ba --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_keyless/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 976087151, + "block_height": 189192230, + "parent_signature_type": "single_key_signature", + "sender": "0x2702d121810b0dd82da7fe72abc0972cb087cd8f37b55367a8fb0b2faead0763", + "sequence_number": 0, + "max_gas_amount": "200000", + "expiration_timestamp_secs": "2024-06-10T15:51:29", + "gas_unit_price": "100", + "timestamp": "2024-06-10T15:51:10.170250", + "entry_function_id_str": "0x1::aptos_account::transfer_coins", + "epoch": 7324 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/signatures.json new file mode 100644 index 000000000..1fbf5f6f1 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 527013476, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 162964512, + "signer": "0x12cb0b6725601b943da69cfaee34e4952ff569c26943602a88029f446c7ef165", + "is_sender_primary": true, + "type_": "single_sender_secp256k1_ecdsa_signature", + "public_key": "0x044510e315de515f02b687c29bba8052d696151e0248bedb805cd140fc98c80b447fdb4f26ba35caf5109c2ca567eb3b08d80774076451e16443a23ccb4f1a949c", + "signature": "0xef3bc8e8d0a78e6cb10545ed4b1086a88e7c63587e728dec794c9b25397476cd32a7e8f9bb1b6339a383e03c07003596c04602ecbc5c5c473c200d81661733bc", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/user_transactions.json new file mode 100644 index 000000000..002b8edf3 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_secp/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 527013476, + "block_height": 162964512, + "parent_signature_type": "single_key_signature", + "sender": "0x12cb0b6725601b943da69cfaee34e4952ff569c26943602a88029f446c7ef165", + "sequence_number": 6, + "max_gas_amount": "48", + "expiration_timestamp_secs": "2024-03-29T13:51:42", + "gas_unit_price": "100", + "timestamp": "2024-03-29T13:51:13.448212", + "entry_function_id_str": "0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap", + "epoch": 6429 + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/signatures.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/signatures.json new file mode 100644 index 000000000..47094bf7f --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/signatures.json @@ -0,0 +1,15 @@ +[ + { + "transaction_version": 551057865, + "multi_agent_index": 0, + "multi_sig_index": 0, + "transaction_block_height": 168677104, + "signer": "0x7f94f5f1150b0669e8304613da151ef48b9b208669f49b0d42e58cc140433e54", + "is_sender_primary": true, + "type_": "single_sender_webauthn_signature", + "public_key": "0x0402dd47683d0a908249f0da345f3d15b4b329bb8310540e8918beb98e7f2758720bcdcbadb01d43b079140bcd6e56c95966dbb6f780d82974f26b41c543118f77", + "signature": "0x0040211a74c7299c4aa60f6fe75bc755694ba7276ad75d922340612fb08429e006b54ff2545268b6ea71ced3e490a9aa587165fa71a0592d1bdac1be7937a2a72a4725c58974259844ca2dcbed5655a0efae85cf745db11942678dfd90b1d5dd8542e91d000000007b7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22514e316168706571534277376f6e77697668396e4d61774b657749446859613856535a3156335347725655222c226f726967696e223a2268747470733a2f2f706173736b65792d64656d6f2e70616765732e646576227d", + "threshold": 1, + "public_key_indices": [] + } +] \ No newline at end of file diff --git a/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/user_transactions.json b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/user_transactions.json new file mode 100644 index 000000000..1754f4db8 --- /dev/null +++ b/rust/integration-tests/sdk_expected_db_output_files/user_transaction_processor/test_single_sender_webauth/user_transactions.json @@ -0,0 +1,15 @@ +[ + { + "version": 551057865, + "block_height": 168677104, + "parent_signature_type": "single_key_signature", + "sender": "0x7f94f5f1150b0669e8304613da151ef48b9b208669f49b0d42e58cc140433e54", + "sequence_number": 0, + "max_gas_amount": "200000", + "expiration_timestamp_secs": "2024-04-13T17:59:46", + "gas_unit_price": "100", + "timestamp": "2024-04-13T17:59:30.751467", + "entry_function_id_str": "0x1::aptos_account::transfer_coins", + "epoch": 6620 + } +] \ No newline at end of file diff --git a/rust/integration-tests/src/diff_test_helper/user_transaction_processor.rs b/rust/integration-tests/src/diff_test_helper/user_transaction_processor.rs index d267d9bf1..4f389dbad 100644 --- a/rust/integration-tests/src/diff_test_helper/user_transaction_processor.rs +++ b/rust/integration-tests/src/diff_test_helper/user_transaction_processor.rs @@ -28,6 +28,7 @@ pub fn load_data( let sig_result = sig_dsl::signatures .filter(sig_dsl::transaction_version.eq_any(&txn_versions)) .then_order_by(sig_dsl::transaction_version.asc()) + .then_order_by(sig_dsl::multi_sig_index) .load::(conn)?; result_map.insert("signatures".to_string(), serde_json::to_value(&sig_result)?); diff --git a/rust/integration-tests/src/sdk_tests/mod.rs b/rust/integration-tests/src/sdk_tests/mod.rs index 51eaf29d3..090f96825 100644 --- a/rust/integration-tests/src/sdk_tests/mod.rs +++ b/rust/integration-tests/src/sdk_tests/mod.rs @@ -34,6 +34,9 @@ pub mod objects_processor_tests; #[cfg(test)] pub mod stake_processor_tests; +#[cfg(test)] +pub mod user_transaction_processor_tests; + #[allow(dead_code)] pub const DEFAULT_OUTPUT_FOLDER: &str = "sdk_expected_db_output_files"; diff --git a/rust/integration-tests/src/sdk_tests/user_transaction_processor_tests.rs b/rust/integration-tests/src/sdk_tests/user_transaction_processor_tests.rs new file mode 100644 index 000000000..70a7986d0 --- /dev/null +++ b/rust/integration-tests/src/sdk_tests/user_transaction_processor_tests.rs @@ -0,0 +1,190 @@ +use ahash::AHashMap; +use aptos_indexer_testing_framework::sdk_test_context::SdkTestContext; +use sdk_processor::config::{ + db_config::{DbConfig, PostgresConfig}, + indexer_processor_config::IndexerProcessorConfig, + processor_config::{DefaultProcessorConfig, ProcessorConfig}, +}; +use std::collections::HashSet; + +pub fn setup_user_txn_processor_config( + test_context: &SdkTestContext, + db_url: &str, +) -> (IndexerProcessorConfig, &'static str) { + let transaction_stream_config = test_context.create_transaction_stream_config(); + let postgres_config = PostgresConfig { + connection_string: db_url.to_string(), + db_pool_size: 100, + }; + + let db_config = DbConfig::PostgresConfig(postgres_config); + let default_processor_config = DefaultProcessorConfig { + per_table_chunk_sizes: AHashMap::new(), + channel_size: 100, + deprecated_tables: HashSet::new(), + }; + + let processor_config = ProcessorConfig::UserTransactionProcessor(default_processor_config); + + let processor_name = processor_config.name(); + ( + IndexerProcessorConfig { + processor_config, + transaction_stream_config, + db_config, + backfill_config: None, + }, + processor_name, + ) +} + +#[allow(clippy::needless_return)] +#[cfg(test)] +mod sdk_user_txn_processor_tests { + use super::setup_user_txn_processor_config; + use crate::{ + diff_test_helper::user_transaction_processor::load_data, + sdk_tests::{ + run_processor_test, setup_test_environment, validate_json, DEFAULT_OUTPUT_FOLDER, + }, + }; + use aptos_indexer_test_transactions::{ + IMPORTED_MAINNET_TXNS_1803170308_USER_TXN_MULTI_KEY_KEYLESS, + IMPORTED_MAINNET_TXNS_2175935_USER_TXN_MULTI_ED25519, + IMPORTED_MAINNET_TXNS_407418623_USER_TXN_SINGLE_KEY_SECP256K1_ECDSA, + IMPORTED_MAINNET_TXNS_464961735_USER_TXN_SINGLE_KEY_ED25519, + IMPORTED_MAINNET_TXNS_527013476_USER_TXN_SINGLE_SENDER_SECP256K1_ECDSA, + IMPORTED_MAINNET_TXNS_551057865_USER_TXN_SINGLE_SENDER_WEBAUTH, + IMPORTED_MAINNET_TXNS_590098441_USER_TXN_SINGLE_SENDER_ED25519, + IMPORTED_MAINNET_TXNS_685_USER_TXN_ED25519, + IMPORTED_MAINNET_TXNS_976087151_USER_TXN_SINGLE_SENDER_KEYLESS, + }; + use aptos_indexer_testing_framework::{cli_parser::get_test_config, database::TestDatabase}; + use sdk_processor::processors::user_transaction_processor::UserTransactionProcessor; + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_multi_key_keyless_signature() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_1803170308_USER_TXN_MULTI_KEY_KEYLESS, + Some("test_multi_key_keyless_signature".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_multi_ed25519() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_2175935_USER_TXN_MULTI_ED25519, + Some("test_multi_ed25519".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_key_secp() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_407418623_USER_TXN_SINGLE_KEY_SECP256K1_ECDSA, + Some("test_single_key_secp".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_key_ed25519() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_464961735_USER_TXN_SINGLE_KEY_ED25519, + Some("test_single_key_ed25519".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_sender_secp() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_527013476_USER_TXN_SINGLE_SENDER_SECP256K1_ECDSA, + Some("test_single_sender_secp".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_sender_webauth() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_551057865_USER_TXN_SINGLE_SENDER_WEBAUTH, + Some("test_single_sender_webauth".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_sender_ed25519() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_590098441_USER_TXN_SINGLE_SENDER_ED25519, + Some("test_single_sender_ed25519".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_ed25519() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_685_USER_TXN_ED25519, + Some("test_single_ed25519".to_string()), + ) + .await; + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_single_sender_keyless() { + process_single_transactions( + IMPORTED_MAINNET_TXNS_976087151_USER_TXN_SINGLE_SENDER_KEYLESS, + Some("test_single_sender_keyless".to_string()), + ) + .await; + } + + // Helper function to abstract out the transaction processing + async fn process_single_transactions(txn: &[u8], test_case_name: Option) { + let (diff_flag, custom_output_path) = get_test_config(); + let output_path = custom_output_path.unwrap_or_else(|| DEFAULT_OUTPUT_FOLDER.to_string()); + + let (db, mut test_context) = setup_test_environment(&[txn]).await; + + let db_url = db.get_db_url(); + let (indexer_processor_config, processor_name) = + setup_user_txn_processor_config(&test_context, &db_url); + + let user_txn_processor = UserTransactionProcessor::new(indexer_processor_config) + .await + .expect("Failed to create UserTransactionProcessor"); + + match run_processor_test( + &mut test_context, + user_txn_processor, + load_data, + db_url, + diff_flag, + output_path.clone(), + test_case_name.clone(), + ) + .await + { + Ok(mut db_value) => { + let _ = validate_json( + &mut db_value, + test_context.get_request_start_version(), + processor_name, + output_path.clone(), + test_case_name, + ); + }, + Err(e) => { + panic!( + "Test failed on transactions {:?} due to processor error: {}", + test_context.get_test_transaction_versions(), + e + ); + }, + } + } +}