Skip to content

Commit

Permalink
Adds successful transaction in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gupnik committed Jan 3, 2025
1 parent 14d0c97 commit 5533663
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TestAptosSigner {

@Test
fun AptosTransactionBlindSigningWithABI() {
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x4eb6a65b1453e3f224d92b07aa8bf51eaa8b3f5bb5172cf28ebe62b527ae1010/payload?network=mainnet
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x1ee2aa55382bf6b5a9f7a7f2b2066e16979489c6b2868704a2cf2c482f12b5ca/payload?network=mainnet
val key =
"5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec".toHexBytesInByteString()

Expand All @@ -91,11 +91,11 @@ class TestAptosSigner {
""".trimIndent()
val signingInput = Aptos.SigningInput.newBuilder()
.setChainId(1)
.setExpirationTimestampSecs(3664390082)
.setExpirationTimestampSecs(1735902711)
.setGasUnitPrice(100)
.setMaxGasAmount(100011)
.setMaxGasAmount(50000)
.setSender("0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30")
.setSequenceNumber(66)
.setSequenceNumber(69)
.setAnyEncoded(payloadJson)
.setPrivateKey(key)
.setAbi("""
Expand All @@ -110,15 +110,15 @@ class TestAptosSigner {
val result = AnySigner.sign(signingInput, CoinType.APTOS, Aptos.SigningOutput.parser())
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.rawTxn.toByteArray())),
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada0000000001"
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c577670000000001"
)
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.authenticator.signature.toByteArray())),
"9f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903"
"13dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304"
)
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.encoded.toByteArray())),
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada00000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c409f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903"
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c5776700000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c4013dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304"
)
}

Expand Down
22 changes: 11 additions & 11 deletions rust/chains/tw_aptos/tests/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,17 +786,17 @@ fn test_aptos_blind_sign() {
}"#);
}

// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x4eb6a65b1453e3f224d92b07aa8bf51eaa8b3f5bb5172cf28ebe62b527ae1010/payload?network=mainnet
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x1ee2aa55382bf6b5a9f7a7f2b2066e16979489c6b2868704a2cf2c482f12b5ca/payload?network=mainnet
#[test]
fn test_aptos_blind_sign_with_abi() {
let input = setup_proto_transaction(
"0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", // Sender's address
"5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec", // Keypair
"blind_sign_json",
66, // Sequence number
69, // Sequence number
1,
100011,
3664390082,
50000,
1735902711,
100,
r#"{
"function": "0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::controller::deposit",
Expand All @@ -819,13 +819,13 @@ fn test_aptos_blind_sign_with_abi() {
);
let output = Signer::sign_proto(input);
test_tx_result(output,
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada0000000001", // Expected raw transaction bytes
"9f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903", // Expected signature
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada00000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c409f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903", // Expected encoded transaction
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c577670000000001", // Expected raw transaction bytes
"13dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304", // Expected signature
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c5776700000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c4013dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304", // Expected encoded transaction
r#"{
"expiration_timestamp_secs": "3664390082",
"expiration_timestamp_secs": "1735902711",
"gas_unit_price": "100",
"max_gas_amount": "100011",
"max_gas_amount": "50000",
"payload": {
"function": "0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::controller::deposit",
"type_arguments": [
Expand All @@ -839,10 +839,10 @@ fn test_aptos_blind_sign_with_abi() {
"type": "entry_function_payload"
},
"sender": "0x7968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30",
"sequence_number": "66",
"sequence_number": "69",
"signature": {
"public_key": "0xea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c",
"signature": "0x9f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903",
"signature": "0x13dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304",
"type": "ed25519_signature"
}
}"#);
Expand Down
14 changes: 7 additions & 7 deletions swift/Tests/Blockchains/AptosTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AptosTests: XCTestCase {
}

func testBlindSignWithABI() {
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x4eb6a65b1453e3f224d92b07aa8bf51eaa8b3f5bb5172cf28ebe62b527ae1010/payload?network=mainnet
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x1ee2aa55382bf6b5a9f7a7f2b2066e16979489c6b2868704a2cf2c482f12b5ca/payload?network=mainnet
let payloadJson = """
{
"function": "0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::controller::deposit",
Expand All @@ -74,10 +74,10 @@ class AptosTests: XCTestCase {
let input = AptosSigningInput.with {
$0.chainID = 1
$0.anyEncoded = payloadJson
$0.expirationTimestampSecs = 3664390082
$0.expirationTimestampSecs = 1735902711
$0.gasUnitPrice = 100
$0.maxGasAmount = 100011
$0.sequenceNumber = 66
$0.maxGasAmount = 50000
$0.sequenceNumber = 69
$0.sender = "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30"
$0.privateKey = privateKeyData
$0.abi = """
Expand All @@ -89,9 +89,9 @@ class AptosTests: XCTestCase {
"""
}
let output: AptosSigningOutput = AnySigner.sign(input: input, coin: .aptos)
let expectedRawTx = "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada0000000001"
let expectedSignature = "9f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903"
let expectedSignedTx = "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada00000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c409f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903"
let expectedRawTx = "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c577670000000001"
let expectedSignature = "13dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304"
let expectedSignedTx = "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c5776700000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c4013dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304"
XCTAssertEqual(output.rawTxn.hexString, expectedRawTx)
XCTAssertEqual(output.authenticator.signature.hexString, expectedSignature)
XCTAssertEqual(output.encoded.hexString, expectedSignedTx)
Expand Down
14 changes: 7 additions & 7 deletions tests/chains/Aptos/TWAnySignerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ TEST(TWAnySignerAptos, TxSign) {
}

TEST(TWAnySignerAptos, TxSignWithABI) {
// Successfully broadcasted https://explorer.aptoslabs.com/txn/0x4eb6a65b1453e3f224d92b07aa8bf51eaa8b3f5bb5172cf28ebe62b527ae1010/payload?network=mainnet
// Successfully broadcasted https://explorer.aptoslabs.com/txn/0x1ee2aa55382bf6b5a9f7a7f2b2066e16979489c6b2868704a2cf2c482f12b5ca/payload?network=mainnet
Proto::SigningInput input;
input.set_sender("0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30");
input.set_sequence_number(66);
input.set_max_gas_amount(100011);
input.set_sequence_number(69);
input.set_max_gas_amount(50000);
input.set_gas_unit_price(100);
input.set_expiration_timestamp_secs(3664390082);
input.set_expiration_timestamp_secs(1735902711);
input.set_chain_id(1);
input.set_any_encoded(R"(
{
Expand All @@ -89,9 +89,9 @@ TEST(TWAnySignerAptos, TxSignWithABI) {
input.set_private_key(privateKey.bytes.data(), privateKey.bytes.size());
Proto::SigningOutput output;
ANY_SIGN(input, TWCoinTypeAptos);
ASSERT_EQ(hex(output.raw_txn()), "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada0000000001");
ASSERT_EQ(hex(output.authenticator().signature()), "9f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903");
ASSERT_EQ(hex(output.encoded()), "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304200000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e740880969800000000000100ab860100000000006400000000000000c2276ada00000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c409f9a5a075b643ed7f2f8c6afb492dc384ad0b9600645ece7394e0060b14d440c9103bd00cc50f22c473c21ff3a7f0475d8600b19c83184b71722f0d3f8472903");
ASSERT_EQ(hex(output.raw_txn()), "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c577670000000001");
ASSERT_EQ(hex(output.authenticator().signature()), "13dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304");
ASSERT_EQ(hex(output.encoded()), "07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c5776700000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c4013dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304");
}

} // namespace TW::Aptos::tests

0 comments on commit 5533663

Please sign in to comment.