From 1ffbd9e95790ef9fb64e50a977393ec706800de2 Mon Sep 17 00:00:00 2001 From: JasonTulp Date: Fri, 31 May 2024 09:06:06 +1200 Subject: [PATCH 1/3] Address PR comments --- ethy-gadget/src/gossip.rs | 6 +++--- runtime/src/lib.rs | 2 +- runtime/src/tests/evm_tests.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ethy-gadget/src/gossip.rs b/ethy-gadget/src/gossip.rs index a377cd8b5..f6ed929f3 100644 --- a/ethy-gadget/src/gossip.rs +++ b/ethy-gadget/src/gossip.rs @@ -415,7 +415,7 @@ mod tests { assert_validation_result!(ValidationResult::ProcessAndKeep(_), result); assert!(gv.is_tracking_event(&event_id)); - // set the finalized block number to 6. try to validate now. should fail since out of live + // set the finalized block number to 7. try to validate now. should fail since out of live // window. i.e. WINDOW_SIZE = 5 let block_hashes = net.peer(0).push_blocks(7, false); net.run_until_sync().await; @@ -464,7 +464,7 @@ mod tests { let result = gv.message_expired()(topic::(), witness.clone().encode().as_ref()); assert_eq!(result, false); - // set the finalized block number to 6. try to validate now. should fail since out of live + // set the finalized block number to 7. try to validate now. should fail since out of live // window. i.e. WINDOW_SIZE = 5 let block_hashes = net.peer(0).push_blocks(7, false); net.run_until_sync().await; @@ -518,7 +518,7 @@ mod tests { ); assert_eq!(result, true); - // set the finalized block number to 6. try to validate now. should fail since out of live + // set the finalized block number to 7. try to validate now. should fail since out of live // window. i.e. WINDOW_SIZE = 5 let block_hashes = net.peer(0).push_blocks(7, false); net.run_until_sync().await; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 9b1605bef..cada37847 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -132,7 +132,7 @@ mod staking; use staking::OnChainAccuracy; -pub mod migrations; +mod migrations; mod weights; use crate::impls::{ diff --git a/runtime/src/tests/evm_tests.rs b/runtime/src/tests/evm_tests.rs index f43a95230..4e3957510 100644 --- a/runtime/src/tests/evm_tests.rs +++ b/runtime/src/tests/evm_tests.rs @@ -256,7 +256,7 @@ fn call_with_fee_preferences_futurepass_proxy_extrinsic() { RawOrigin::Signed(alice()).into(), payment_asset, alice(), - 20_000_000_000_000_000 + 10_000_000_000_000_000 )); // add liquidity to the dex, this will allow for exchange internally when the call is made From 2b35173cbe5abedfcc93214b640e1464d44dd0df Mon Sep 17 00:00:00 2001 From: JasonTulp Date: Fri, 31 May 2024 10:34:34 +1200 Subject: [PATCH 2/3] Fix some XRPL tests --- e2e/test/XRPL.test.ts | 5 ++- pallet/vortex-distribution/src/lib.rs | 2 +- pallet/xrpl/src/tests.rs | 46 ++++++++++++--------------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/e2e/test/XRPL.test.ts b/e2e/test/XRPL.test.ts index 8993a15ba..0057d1b05 100644 --- a/e2e/test/XRPL.test.ts +++ b/e2e/test/XRPL.test.ts @@ -186,7 +186,7 @@ describe("XRPL pallet", () => { await finalizeTx(alith, api.tx.assets.transfer(GAS_TOKEN_ID, eoa, 2_000_000)); - const extrinsic = api.tx.system.remark("hi"); + const extrinsic = api.tx.system.remark("Mischief Managed"); const hashedExtrinsicWithoutPrefix = blake256(extrinsic.toHex().slice(6)).toString(); const maxBlockNumber = +(await api.query.system.number()).toString() + 5; const nonce = ((await api.query.system.account(eoa)).toJSON() as any)?.nonce; @@ -213,6 +213,9 @@ describe("XRPL pallet", () => { const encodedSigningMessage = encodeForSigning(xamanJsonTx); const signature = sign(encodedSigningMessage, signerInstance.keypair.privateKey); + console.log("message", message); + console.log("signature", signature); + // execute xaman tx extrinsic const events = await new Promise(async (resolve) => { await api.tx.xrpl.transact(`0x${message}`, `0x${signature}`, extrinsic).send(({ events = [], status }) => { diff --git a/pallet/vortex-distribution/src/lib.rs b/pallet/vortex-distribution/src/lib.rs index e1bba0193..373bd417a 100644 --- a/pallet/vortex-distribution/src/lib.rs +++ b/pallet/vortex-distribution/src/lib.rs @@ -282,7 +282,7 @@ pub mod pallet { if let Err(e) = Self::vtx_dist_offchain_worker(now) { log::info!( target: "vtx-dist", - "error happened in offchain worker at {:?}: {:?}", + "offchain worker not triggered at {:?}: {:?}", now, e, ); diff --git a/pallet/xrpl/src/tests.rs b/pallet/xrpl/src/tests.rs index ff94faf5a..6f8738367 100644 --- a/pallet/xrpl/src/tests.rs +++ b/pallet/xrpl/src/tests.rs @@ -26,18 +26,18 @@ mod self_contained_call { #[test] fn transact_validations() { TestExt::::default().build().execute_with(|| { - // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark + // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark let call = mock::RuntimeCall::System(frame_system::Call::remark { remark: Default::default() }); - let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D48303A303A353A303A35633933633236383339613137636235616366323765383961616330306639646433663531643161316161346234383266363930663634333633396665383732E1F1").unwrap(); - assert_ok!(Xrpl::transact(frame_system::RawOrigin::None.into(), BoundedVec::truncate_from(tx_bytes.clone()), BoundedVec::default(), Box::new(call))); - }); + let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D48303A303A353A303A35633933633236383339613137636235616366323765383961616330306639646433663531643161316161346234383266363930663634333633396665383732E1F1").unwrap(); + assert_ok!(Xrpl::transact(frame_system::RawOrigin::None.into(), BoundedVec::truncate_from(tx_bytes.clone()), BoundedVec::default(), Box::new(call))); + }); } #[test] fn extrinsic_cannot_perform_privileged_operations() { TestExt::::default().build().execute_with(|| { let call = mock::RuntimeCall::System(frame_system::Call::set_code { code: Default::default() }); - // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::set_code + // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::set_code let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D48303A303A353A303A66633730373832313235333862623238393633373338393034303237373630313464393765303033656136393430303533303538386134383434393662333337E1F1").unwrap(); // executing xrpl encoded transaction fails since caller is not root/sudo account @@ -69,8 +69,6 @@ mod self_contained_call { }); } - // TODO Fix this once e2e tests are building - #[ignore] #[test] fn validate_nonce_too_high() { TestExt::::default() @@ -80,10 +78,10 @@ mod self_contained_call { let call = mock::RuntimeCall::System(frame_system::Call::remark { remark: b"Mischief Managed".to_vec() }); // encoded call for: genesis_hash = 0x0, nonce = 5, max_block_number = 5, tip = 0, extrinsic = System::remark; validates nonce too high - let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A353A353A303A33623832663037383031653632636437383966316233636333353936383236313436613163353136666165613766633633333263643362323563646666316331E1F1").unwrap(); + let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A353A353A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap(); let xt: mock::UncheckedExtrinsicT = fp_self_contained::UncheckedExtrinsic::new_unsigned(mock::RuntimeCall::Xrpl(crate::Call::transact { encoded_msg: BoundedVec::truncate_from(tx_bytes.clone()), - signature: BoundedVec::truncate_from(hex::decode("3045022100BD4846922C600DEDE58A0B1E15D728671538209DBE6A5A03ECE3C9731D7F5068022027FC270D8DE1FCBE3D7B76931BF1980F0E4BCDA6A764FC76E659620AE91C7841").unwrap()), + signature: BoundedVec::truncate_from(hex::decode("3045022100C17C9D3D04DB3B77BDA2F8C91B8A30E0E28CC324FAE88EE54A1E3A8A2CA7BF1B02201BCBBB1A66695CFEA0BA3216BE06DD026D520A05E14960C047AB9986152FB35F").unwrap()), call: Box::new(call.clone()), })); @@ -111,8 +109,8 @@ mod self_contained_call { // validate self contained extrinsic fails, call provided is not signed hashed extrinsic in memo data let xt: mock::UncheckedExtrinsicT = fp_self_contained::UncheckedExtrinsic::new_unsigned(mock::RuntimeCall::Xrpl(crate::Call::transact { - encoded_msg: BoundedVec::truncate_from(hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D0A303A303A353A303A3030E1F1").unwrap()), - signature: BoundedVec::truncate_from(hex::decode("304502210081C0EFD0B5C85AC8C20765B95B44DCD0891619E83529A63A2350907B341EE168022006365C3AB530A1D529606D6EDDE18C76ECF42334FF0DC2140AD392C20305F898").unwrap()), + encoded_msg: BoundedVec::truncate_from(hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap()), + signature: BoundedVec::truncate_from(hex::decode("304402205CD628B33CD2A89D735EBC139F21A3F2F138F7D687BBAF3E2CDFBBF8951919DC02204B65FC7FF3C2C1B1EEF10186CF6BDAA1C96E8F0814099EE5811C12F65E26A81E").unwrap()), call: Box::new(call.clone()), })); assert_err!( @@ -122,8 +120,6 @@ mod self_contained_call { }); } - // TODO Fix this once e2e tests are building - #[ignore] #[test] fn validate_transaction_signature() { TestExt::::default() @@ -133,7 +129,7 @@ mod self_contained_call { let call = mock::RuntimeCall::System(frame_system::Call::remark { remark: b"Mischief Managed".to_vec() }); // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark - let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33623832663037383031653632636437383966316233636333353936383236313436613163353136666165613766633633333263643362323563646666316331E1F1").unwrap(); + let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap(); // validate self contained extrinsic is invalid (no signature) let xt: mock::UncheckedExtrinsicT = fp_self_contained::UncheckedExtrinsic::new_unsigned(mock::RuntimeCall::Xrpl(crate::Call::transact { @@ -160,7 +156,7 @@ mod self_contained_call { // validate self contained extrinsic fails, user does not have funds to pay for transaction (corrected signature) let xt: mock::UncheckedExtrinsicT = fp_self_contained::UncheckedExtrinsic::new_unsigned(mock::RuntimeCall::Xrpl(crate::Call::transact { encoded_msg: BoundedVec::truncate_from(tx_bytes.clone()), - signature: BoundedVec::truncate_from(hex::decode("3045022100F21BB8B86C394E5A383881E3EFA7D2879D2E66E76174F7494C580B402643F45E02200DAB3D5E3B39E61E1020240BA718761EE9EFF148DFBAEC288EFFB4E3FD97DA1D").unwrap()), + signature: BoundedVec::truncate_from(hex::decode("3045022100AB93610B5A278148E75CC28E8308B963C6439B906D4F5EA9A38BA01567D061B1022021A5D789AD9D98BA6B63FD19676FF2ED72071C14BD8FE1745E72F769E03E005D").unwrap()), call: Box::new(call.clone()), })); assert_err!( @@ -176,8 +172,6 @@ mod self_contained_call { }); } - // TODO Fix this once e2e tests are building - #[ignore] #[test] fn ecdsa_system_remark_extrinsic_from_message_success() { TestExt::::default() @@ -186,9 +180,9 @@ mod self_contained_call { .execute_with(|| { let call = mock::RuntimeCall::System(frame_system::Call::remark { remark: b"Mischief Managed".to_vec() }); - // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark - let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33623832663037383031653632636437383966316233636333353936383236313436613163353136666165613766633633333263643362323563646666316331E1F1").unwrap(); - let signature = hex::decode("3045022100F21BB8B86C394E5A383881E3EFA7D2879D2E66E76174F7494C580B402643F45E02200DAB3D5E3B39E61E1020240BA718761EE9EFF148DFBAEC288EFFB4E3FD97DA1D").unwrap(); + // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark + let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580732102509540919FAACF9AB52146C9AA40DB68172D83777250B28E4679176E49CCDD9F81148E6106F6E98E7B21BFDFBFC3DEBA0EDED28A047AF9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap(); + let signature = hex::decode("3045022100AB93610B5A278148E75CC28E8308B963C6439B906D4F5EA9A38BA01567D061B1022021A5D789AD9D98BA6B63FD19676FF2ED72071C14BD8FE1745E72F769E03E005D").unwrap(); // fund the user with XRP (to pay for tx fees) let tx = XRPLTransaction::try_from(tx_bytes.as_bytes_ref()).unwrap(); @@ -231,7 +225,7 @@ mod self_contained_call { System::assert_last_event(mock::RuntimeEvent::System( frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { - weight: Weight::from_all(311_960_000), + weight: Weight::from_parts(396_839_240, 220_300_000), class: DispatchClass::Normal, pays_fee: Pays::Yes, }, @@ -252,7 +246,7 @@ mod self_contained_call { }); } - // TODO - enable once e2e ready? + // TODO - This test is still failing.. #[ignore] #[test] fn ed25519_system_remark_extrinsic_from_message_success() { @@ -262,9 +256,9 @@ mod self_contained_call { .execute_with(|| { let call = mock::RuntimeCall::System(frame_system::Call::remark { remark: b"Mischief Managed".to_vec() }); - // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark - let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C25807321EDFB2A3A850B43E24D2700532EF1F9CCB2475DFF4F62B634B0C58845F23C26396581145116224CEF7355137BEBBA8E277A9BE18E0596E7F9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33623832663037383031653632636437383966316233636333353936383236313436613163353136666165613766633633333263643362323563646666316331E1F1").unwrap(); - let signature = hex::decode("7B1FBDAC5A646259451329E9D57DD4C1D5AF5970F46232E893408001E762E9DB68E30E9E9D023229EAA290ACB6AFF1D527025161C7649DC61366C0574AC07A02").unwrap(); + // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark + let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C25807321EDFB2A3A850B43E24D2700532EF1F9CCB2475DFF4F62B634B0C58845F23C26396581145116224CEF7355137BEBBA8E277A9BE18E0596E7F9EA7C0965787472696E7369637D89323331393432326633646639643133626262363561313863393236333737343636323033343865383466376634663339663931376636636338313065636564313A313A3439333A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap(); + let signature = hex::decode("9891D5A458021182FE599329147C2C38870F31351DBD1CE4589DC9F8F9896C66286D23F474CC8AD5B4EB39707D52F6821E6391B624CA785603A4299672C3E506").unwrap(); // fund the user with XRP (to pay for tx fees) let tx = XRPLTransaction::try_from(tx_bytes.as_bytes_ref()).unwrap(); @@ -307,7 +301,7 @@ mod self_contained_call { System::assert_last_event(mock::RuntimeEvent::System( frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { - weight: Weight::from_all(311_960_000), + weight: Weight::from_parts(396_839_240, 220_300_000), class: DispatchClass::Normal, pays_fee: Pays::Yes, }, From b410bf178130bfbf9d28ce62e057c8eb8b8bb44d Mon Sep 17 00:00:00 2001 From: JasonTulp Date: Fri, 31 May 2024 10:47:45 +1200 Subject: [PATCH 3/3] Fix ED25519 test --- e2e/test/XRPL.test.ts | 50 ++++++++++++++++++++++++++++++++++++---- pallet/xrpl/src/tests.rs | 6 ++--- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/e2e/test/XRPL.test.ts b/e2e/test/XRPL.test.ts index 0057d1b05..5720a0137 100644 --- a/e2e/test/XRPL.test.ts +++ b/e2e/test/XRPL.test.ts @@ -43,7 +43,7 @@ describe("XRPL pallet", () => { after(async () => await node.stop()); // NOTE: use this test to generate a valid xaman tx (msg + signature) for mock runtime tests - it.skip("debug tx message and signature", async () => { + it.skip("debug ECDSA tx message and signature", async () => { // const user = Wallet.createRandom(); const publicKey = computePublicKey(alith.publicKey, true); // console.log(hexToU8a(publicKey)); @@ -80,6 +80,51 @@ describe("XRPL pallet", () => { console.log("signature", signature); }); + // NOTE: use this test to generate a valid xaman tx (msg + signature) for mock runtime tests + it.skip("debug ED25519 tx message and signature", async () => { + // const user = Wallet.createRandom(); + // const publicKey = computePublicKey(alith.publicKey, true); + const importedAccount = AccountLib.derive.familySeed("sEdS4rAgVysUtD5Zmm9F8i8uJBGik4K"); + const signerInstance = AccountLib.derive.privatekey(importedAccount.keypair.privateKey!); + const publicKey = computePublicKey(`0x${signerInstance.keypair.publicKey!}`, true); + const eoa = Web3.utils.toChecksumAddress( + // remove "ED" prefix from public key to compute EOA + // keccak hash produces 32 bytes (64 chars) - take last 20 bytes (40 chars) + // remove "0x" prefix from keccak hash output (2 chars) + // get last 20 bytes of the keccak hash output (12 bytes - 24 chars) + "0x" + keccak256(hexToU8a(`0x${publicKey.slice(4)}`)).slice(26), + ); + + await finalizeTx(alith, api.tx.assets.transfer(GAS_TOKEN_ID, eoa, 2_000_000)); + + genesisHash = "0000000000000000000000000000000000000000000000000000000000000000"; + const extrinsic = api.tx.system.remark("Mischief Managed"); + const hashedExtrinsicWithoutPrefix = blake256(extrinsic.toHex().slice(6)).toString(); + + const xamanJsonTx = { + AccountTxnID: "16969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C2580", + SigningPubKey: publicKey.slice(2), + Account: deriveAddress(publicKey.slice(2)), + Memos: [ + { + Memo: { + MemoType: stringToHex("extrinsic"), + // remove `0x` from extrinsic hex string + MemoData: stringToHex(`${genesisHash}:0:5:0:${hashedExtrinsicWithoutPrefix}`), + }, + }, + ], + }; + + // sign xaman tx + const message = encode(xamanJsonTx); + const encodedSigningMessage = encodeForSigning(xamanJsonTx); + const signature = sign(encodedSigningMessage, signerInstance.keypair.privateKey); + + console.log("message", message); + console.log("signature", signature); + }); + it("can submit system remark extrinsic - using ecdsa signature", async () => { const user = Wallet.createRandom(); const publicKey = computePublicKey(user.publicKey, true); @@ -213,9 +258,6 @@ describe("XRPL pallet", () => { const encodedSigningMessage = encodeForSigning(xamanJsonTx); const signature = sign(encodedSigningMessage, signerInstance.keypair.privateKey); - console.log("message", message); - console.log("signature", signature); - // execute xaman tx extrinsic const events = await new Promise(async (resolve) => { await api.tx.xrpl.transact(`0x${message}`, `0x${signature}`, extrinsic).send(({ events = [], status }) => { diff --git a/pallet/xrpl/src/tests.rs b/pallet/xrpl/src/tests.rs index 6f8738367..39f1d395b 100644 --- a/pallet/xrpl/src/tests.rs +++ b/pallet/xrpl/src/tests.rs @@ -246,8 +246,6 @@ mod self_contained_call { }); } - // TODO - This test is still failing.. - #[ignore] #[test] fn ed25519_system_remark_extrinsic_from_message_success() { TestExt::::default() @@ -257,8 +255,8 @@ mod self_contained_call { let call = mock::RuntimeCall::System(frame_system::Call::remark { remark: b"Mischief Managed".to_vec() }); // encoded call for: genesis_hash = 0x0, nonce = 0, max_block_number = 5, tip = 0, extrinsic = System::remark - let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C25807321EDFB2A3A850B43E24D2700532EF1F9CCB2475DFF4F62B634B0C58845F23C26396581145116224CEF7355137BEBBA8E277A9BE18E0596E7F9EA7C0965787472696E7369637D89323331393432326633646639643133626262363561313863393236333737343636323033343865383466376634663339663931376636636338313065636564313A313A3439333A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap(); - let signature = hex::decode("9891D5A458021182FE599329147C2C38870F31351DBD1CE4589DC9F8F9896C66286D23F474CC8AD5B4EB39707D52F6821E6391B624CA785603A4299672C3E506").unwrap(); + let tx_bytes = hex::decode("5916969036626990000000000000000000F236FD752B5E4C84810AB3D41A3C25807321EDFB2A3A850B43E24D2700532EF1F9CCB2475DFF4F62B634B0C58845F23C26396581145116224CEF7355137BEBBA8E277A9BE18E0596E7F9EA7C0965787472696E7369637D87303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303A303A353A303A33376635623466363237376431393362336134663037666135636538373239626137366235343735366238653066616539313531316264313830333032333265E1F1").unwrap(); + let signature = hex::decode("81D0291D0D4CBCD9152F882E09F339F35022617D3BD2178AD8900FD12D8BD1DF69AB9AAD58BA44EF8FC14FA8DB4203272FE24CF5135D25EA5F8492B538C99201").unwrap(); // fund the user with XRP (to pay for tx fees) let tx = XRPLTransaction::try_from(tx_bytes.as_bytes_ref()).unwrap();