Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e8a7ea6
use master branch
zqhxuyuan Jan 10, 2022
336a88a
transfer from self and sibling test
zqhxuyuan Jan 11, 2022
e3e7a49
transfer_to_sibling and test_asset_registry_module err
zqhxuyuan Jan 11, 2022
174cb01
templary fix transfer_to_sibling
zqhxuyuan Jan 12, 2022
56485d9
fix test_asset_registry_module error
zqhxuyuan Jan 12, 2022
a90e450
integration-test feature
zqhxuyuan Jan 13, 2022
e3cec97
asset registry update location works
zqhxuyuan Jan 18, 2022
c28bd79
merge master and update upstream master
zqhxuyuan Jan 24, 2022
b55c7db
Merge branch 'master' into new_reanchor
zqhxuyuan Jan 24, 2022
0130f08
update orml
zqhxuyuan Jan 24, 2022
9b7cc94
update stable-asset
zqhxuyuan Jan 24, 2022
ea65d9e
test serivice with cumulus test runtime works
zqhxuyuan Jan 24, 2022
3a5a5dd
update licence
zqhxuyuan Jan 24, 2022
a0c2abe
update test-service
zqhxuyuan Jan 24, 2022
342fc47
can not produce parachain block with mandala-runtime
zqhxuyuan Jan 24, 2022
9a39c28
fmt
zqhxuyuan Jan 24, 2022
813db74
restore stable-asset
zqhxuyuan Jan 24, 2022
4409862
simple balance works
zqhxuyuan Jan 26, 2022
2122717
test service standalone works
zqhxuyuan Jan 27, 2022
72b3d47
Merge branch 'master' into new_reanchor
zqhxuyuan Jan 27, 2022
a8f59c7
clean and refactor test-service
zqhxuyuan Jan 27, 2022
05aca8d
fix test of Default remove
zqhxuyuan Jan 27, 2022
67cf13e
CheckNonZeroSender
zqhxuyuan Jan 27, 2022
2e7ff7d
add karura native asset test
zqhxuyuan Jan 28, 2022
e7bdec2
apply canical location for manala and acala
zqhxuyuan Jan 28, 2022
102f117
add preimage pallet and migration
zqhxuyuan Jan 28, 2022
f36e29b
v0.9.16
zqhxuyuan Jan 28, 2022
e16462b
rm without_storage_info for some pallet
zqhxuyuan Jan 28, 2022
1033e23
update orml
zqhxuyuan Jan 29, 2022
351281d
review change
zqhxuyuan Jan 29, 2022
6595647
update stable-asset
zqhxuyuan Jan 30, 2022
90974d5
Merge branch 'master' into new_reanchor
xlc Jan 30, 2022
48ea7a3
update NoPreimagePostponement
xlc Jan 30, 2022
b4bedb2
some clippy fix
xlc Jan 30, 2022
312a4bb
update stable-asset
zqhxuyuan Jan 31, 2022
bdbbb1e
update mock
zqhxuyuan Jan 31, 2022
8d714e3
update
zqhxuyuan Jan 31, 2022
1eda19f
fix CI error
zqhxuyuan Feb 1, 2022
c5e6724
cargo test normal
zqhxuyuan Feb 1, 2022
be0d83c
update substrate and fix review
zqhxuyuan Feb 2, 2022
db96b25
Merge branch 'master' into new_reanchor
zqhxuyuan Feb 2, 2022
6834394
fix
zqhxuyuan Feb 2, 2022
bd5d6c5
update evm-tests
zqhxuyuan Feb 2, 2022
dfaec0f
update state_version to 0
zqhxuyuan Feb 3, 2022
91733da
Renamed the NFT trait to InspectExtended
Feb 3, 2022
61e6d43
Updated orml reference
Feb 3, 2022
315e66e
Update orml version
Feb 3, 2022
a29ea50
Merged from Master branch
Feb 3, 2022
8ce9aee
merge master
zqhxuyuan Feb 4, 2022
e9502a3
update polkadot-rc10
zqhxuyuan Feb 4, 2022
e2a734d
update polkadot-rc10
zqhxuyuan Feb 4, 2022
323e8df
merge nft PR #1841
zqhxuyuan Feb 4, 2022
9c795d6
change migration
xlc Feb 4, 2022
10f1ffa
fix Trader
zqhxuyuan Feb 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simple balance works
  • Loading branch information
zqhxuyuan committed Jan 26, 2022
commit 4409862e6988f5896ea7bffbb848dda3eb3c7ed3
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

351 changes: 151 additions & 200 deletions node/e2e-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,11 @@

#![allow(clippy::type_complexity)]

use node_runtime::Runtime;
use sc_executor::NativeElseWasmExecutor;
use sc_service::{TFullBackend, TFullClient};
use sp_runtime::generic::Era;
use std::sync::Arc;
use test_runner::{ChainInfo, SignatureVerificationOverride};

/// A unit struct which implements `NativeExecutionDispatch` feeding in the
/// hard-coded runtime.
pub struct ExecutorDispatch;

impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
type ExtendHostFunctions = (
frame_benchmarking::benchmarking::HostFunctions,
SignatureVerificationOverride,
);

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
node_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
node_runtime::native_version()
}
}

/// ChainInfo implementation.
struct NodeTemplateChainInfo;

impl ChainInfo for NodeTemplateChainInfo {
type Block = node_primitives::Block;
type ExecutorDispatch = ExecutorDispatch;
type Runtime = Runtime;
type RuntimeApi = node_runtime::RuntimeApi;
type SelectChain = sc_consensus::LongestChain<TFullBackend<Self::Block>, Self::Block>;
type BlockImport = Arc<TFullClient<Self::Block, Self::RuntimeApi, NativeElseWasmExecutor<Self::ExecutorDispatch>>>;
type SignedExtras = node_runtime::SignedExtra;
type InherentDataProviders = (
sp_timestamp::InherentDataProvider,
cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider,
);

fn signed_extras(from: <Self::Runtime as frame_system::Config>::AccountId) -> Self::SignedExtras {
(
frame_system::CheckSpecVersion::<Self::Runtime>::new(),
frame_system::CheckTxVersion::<Self::Runtime>::new(),
frame_system::CheckGenesis::<Self::Runtime>::new(),
frame_system::CheckMortality::<Self::Runtime>::from(Era::Immortal),
runtime_common::CheckNonce::<Self::Runtime>::from(frame_system::Pallet::<Self::Runtime>::account_nonce(
from,
)),
frame_system::CheckWeight::<Self::Runtime>::new(),
module_transaction_payment::ChargeTransactionPayment::<Self::Runtime>::from(0),
module_evm::SetEvmOrigin::<Self::Runtime>::new(),
)
}
}
// use node_runtime::Runtime;
// use sc_executor::NativeElseWasmExecutor;
// use sc_service::{TFullBackend, TFullClient};
// use sp_runtime::generic::Era;
// use std::sync::Arc;

#[cfg(test)]
mod tests {
Expand All @@ -86,147 +34,150 @@ mod tests {
use node_service::chain_spec::mandala::dev_testnet_config;
use sp_keyring::sr25519::Keyring::{Alice, Bob};
use sp_runtime::{traits::IdentifyAccount, AccountId32, MultiAddress, MultiSigner};
use test_runner::*;

#[test]
#[ignore] // TODO: fix this after https://github.com/paritytech/substrate/issues/10039
fn test_runner() {
let tokio_runtime = build_runtime().unwrap();
let (rpc, task_manager, client, pool, command_sink, backend) = client_parts::<NodeTemplateChainInfo>(
ConfigOrChainSpec::ChainSpec(Box::new(dev_testnet_config().unwrap()), tokio_runtime.handle().clone()),
)
.unwrap();
let node = Node::<NodeTemplateChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);

tokio_runtime.block_on(async {
// seals blocks
node.seal_blocks(1).await;
// submit extrinsics
let alice = MultiSigner::from(Alice.public()).into_account();
let _hash = node
.submit_extrinsic(
frame_system::Call::remark {
remark: (b"hello world").to_vec(),
},
Some(alice),
)
.await
.unwrap();

// look ma, I can read state.
let _events = node.with_state(|| frame_system::Pallet::<node_runtime::Runtime>::events());
// get access to the underlying client.
let _client = node.client();
})
}

#[test]
#[ignore] // TODO: fix this after https://github.com/paritytech/substrate/issues/10039
fn simple_balances_test() {
let tokio_runtime = build_runtime().unwrap();
let (rpc, task_manager, client, pool, command_sink, backend) = client_parts::<NodeTemplateChainInfo>(
ConfigOrChainSpec::ChainSpec(Box::new(dev_testnet_config().unwrap()), tokio_runtime.handle().clone()),
)
.unwrap();
let node = Node::<NodeTemplateChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);

tokio_runtime.block_on(async {
// submit extrinsics
let alice = MultiSigner::from(Alice.public()).into_account();
let _hash = node
.submit_extrinsic(
frame_system::Call::remark {
remark: (b"hello world").to_vec(),
},
Some(alice),
)
.await
.unwrap();

type Balances = pallet_balances::Pallet<Runtime>;

let (alice, bob) = (MultiSigner::from(Alice.public()), MultiSigner::from(Bob.public()));
let (alice_account_id, bob_account_id) = (alice.into_account(), bob.into_account());

// the function with_state allows us to read state, pretty cool right? :D
let old_balance = node.with_state(|| Balances::free_balance(bob_account_id.clone()));

let amount = 70_000_000_000_000;

// Send extrinsic in action.
let tx = pallet_balances::Call::transfer {
dest: MultiAddress::from(bob_account_id.clone()),
value: amount,
};
node.submit_extrinsic(tx, Some(alice_account_id)).await.unwrap();

// Produce blocks in action, Powered by manual-seal™.
node.seal_blocks(1).await;

// we can check the new state :D
let new_balance = node.with_state(|| Balances::free_balance(bob_account_id.clone()));

// we can now make assertions on how state has changed.
assert_eq!(old_balance + amount, new_balance);
})
}

#[test]
#[ignore] // TODO: fix this after https://github.com/paritytech/substrate/issues/10039
fn transaction_pool_priority_order_test() {
let tokio_runtime = build_runtime().unwrap();
let (rpc, task_manager, client, pool, command_sink, backend) = client_parts::<NodeTemplateChainInfo>(
ConfigOrChainSpec::ChainSpec(Box::new(dev_testnet_config().unwrap()), tokio_runtime.handle().clone()),
)
.unwrap();
let node = Node::<NodeTemplateChainInfo>::new(rpc, task_manager, client, pool, command_sink, backend);

tokio_runtime.block_on(async {
let (alice, bob) = (MultiSigner::from(Alice.public()), MultiSigner::from(Bob.public()));
let (alice_account_id, bob_account_id) = (alice.into_account(), bob.into_account());

// send operational extrinsic
let operational_tx_hash = node.submit_extrinsic(
pallet_sudo::Call::sudo { call: Box::new(module_emergency_shutdown::Call::emergency_shutdown { }.into()) },
Some(alice_account_id),
).await.unwrap();

// send normal extrinsic
let normal_tx_hash = node.submit_extrinsic(
pallet_balances::Call::transfer { dest: MultiAddress::from(bob_account_id.clone()), value: 80_000 },
Some(bob_account_id),
).await.unwrap();

// send unsigned extrinsic
let to: AccountId32 = hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into();
let unsigned_tx_hash = node.submit_extrinsic(
ecosystem_renvm_bridge::Call::mint {
who: to,
p_hash: hex!["67028f26328144de6ef80b8cd3b05e0cefb488762c340d1574c0542f752996cb"],
amount: 93963,
n_hash: hex!["f6a75cc370a2dda6dfc8d016529766bb6099d7fa0d787d9fe5d3a7e60c9ac2a0"],
sig: EcdsaSignature::from_slice(&hex!["defda6eef01da2e2a90ce30ba73e90d32204ae84cae782b485f01d16b69061e0381a69cafed3deb6112af044c42ed0f7c73ee0eec7b533334d31a06db50fc40e1b"]),
},
None,
).await.unwrap();

assert_eq!(node.pool().ready().count(), 3);

// Ensure tx priority order:
// Inherent -> Operational tx -> Unsigned tx -> Signed normal tx
let mut txs = node.pool().ready();
let tx1 = txs.next().unwrap();
let tx2 = txs.next().unwrap();
let tx3 = txs.next().unwrap();

assert_eq!(tx1.hash, operational_tx_hash);
assert_eq!(tx1.priority, 13835064928601523711);

assert_eq!(tx2.hash, unsigned_tx_hash);
assert_eq!(tx2.priority, 1844674407370965161);

assert_eq!(tx3.hash, normal_tx_hash);
assert_eq!(tx3.priority, 42785501349000);
})
}

// #[test]
// #[ignore] // TODO: fix this after https://github.com/paritytech/substrate/issues/10039
// fn test_runner() {
// let tokio_runtime = build_runtime().unwrap();
// let (rpc, task_manager, client, pool, command_sink, backend) =
// client_parts::<NodeTemplateChainInfo>( ConfigOrChainSpec::ChainSpec(Box::
// new(dev_testnet_config().unwrap()), tokio_runtime.handle().clone()), )
// .unwrap();
// let node = Node::<NodeTemplateChainInfo>::new(rpc, task_manager, client, pool, command_sink,
// backend);

// tokio_runtime.block_on(async {
// // seals blocks
// node.seal_blocks(1).await;
// // submit extrinsics
// let alice = MultiSigner::from(Alice.public()).into_account();
// let _hash = node
// .submit_extrinsic(
// frame_system::Call::remark {
// remark: (b"hello world").to_vec(),
// },
// Some(alice),
// )
// .await
// .unwrap();

// // look ma, I can read state.
// let _events = node.with_state(|| frame_system::Pallet::<node_runtime::Runtime>::events());
// // get access to the underlying client.
// let _client = node.client();
// })
// }

// #[test]
// #[ignore] // TODO: fix this after https://github.com/paritytech/substrate/issues/10039
// fn simple_balances_test() {
// let tokio_runtime = build_runtime().unwrap();
// let (rpc, task_manager, client, pool, command_sink, backend) =
// client_parts::<NodeTemplateChainInfo>( ConfigOrChainSpec::ChainSpec(Box::
// new(dev_testnet_config().unwrap()), tokio_runtime.handle().clone()), )
// .unwrap();
// let node = Node::<NodeTemplateChainInfo>::new(rpc, task_manager, client, pool, command_sink,
// backend);

// tokio_runtime.block_on(async {
// // submit extrinsics
// let alice = MultiSigner::from(Alice.public()).into_account();
// let _hash = node
// .submit_extrinsic(
// frame_system::Call::remark {
// remark: (b"hello world").to_vec(),
// },
// Some(alice),
// )
// .await
// .unwrap();

// type Balances = pallet_balances::Pallet<Runtime>;

// let (alice, bob) = (MultiSigner::from(Alice.public()), MultiSigner::from(Bob.public()));
// let (alice_account_id, bob_account_id) = (alice.into_account(), bob.into_account());

// // the function with_state allows us to read state, pretty cool right? :D
// let old_balance = node.with_state(|| Balances::free_balance(bob_account_id.clone()));

// let amount = 70_000_000_000_000;

// // Send extrinsic in action.
// let tx = pallet_balances::Call::transfer {
// dest: MultiAddress::from(bob_account_id.clone()),
// value: amount,
// };
// node.submit_extrinsic(tx, Some(alice_account_id)).await.unwrap();

// // Produce blocks in action, Powered by manual-seal™.
// node.seal_blocks(1).await;

// // we can check the new state :D
// let new_balance = node.with_state(|| Balances::free_balance(bob_account_id.clone()));

// // we can now make assertions on how state has changed.
// assert_eq!(old_balance + amount, new_balance);
// })
// }

// #[test]
// #[ignore] // TODO: fix this after https://github.com/paritytech/substrate/issues/10039
// fn transaction_pool_priority_order_test() {
// let tokio_runtime = build_runtime().unwrap();
// let (rpc, task_manager, client, pool, command_sink, backend) =
// client_parts::<NodeTemplateChainInfo>( ConfigOrChainSpec::ChainSpec(Box::
// new(dev_testnet_config().unwrap()), tokio_runtime.handle().clone()), )
// .unwrap();
// let node = Node::<NodeTemplateChainInfo>::new(rpc, task_manager, client, pool, command_sink,
// backend);

// tokio_runtime.block_on(async {
// let (alice, bob) = (MultiSigner::from(Alice.public()), MultiSigner::from(Bob.public()));
// let (alice_account_id, bob_account_id) = (alice.into_account(), bob.into_account());

// // send operational extrinsic
// let operational_tx_hash = node.submit_extrinsic(
// pallet_sudo::Call::sudo { call: Box::new(module_emergency_shutdown::Call::emergency_shutdown
// { }.into()) }, Some(alice_account_id),
// ).await.unwrap();

// // send normal extrinsic
// let normal_tx_hash = node.submit_extrinsic(
// pallet_balances::Call::transfer { dest: MultiAddress::from(bob_account_id.clone()), value:
// 80_000 }, Some(bob_account_id),
// ).await.unwrap();

// // send unsigned extrinsic
// let to: AccountId32 =
// hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into();
// let unsigned_tx_hash = node.submit_extrinsic(
// ecosystem_renvm_bridge::Call::mint {
// who: to,
// p_hash: hex!["67028f26328144de6ef80b8cd3b05e0cefb488762c340d1574c0542f752996cb"],
// amount: 93963,
// n_hash: hex!["f6a75cc370a2dda6dfc8d016529766bb6099d7fa0d787d9fe5d3a7e60c9ac2a0"],
// sig: EcdsaSignature::from_slice(&hex!["defda6eef01da2e2a90ce30ba73e90d32204ae84cae782b485f01d16b69061e0381a69cafed3deb6112af044c42ed0f7c73ee0eec7b533334d31a06db50fc40e1b"]),
// },
// None,
// ).await.unwrap();

// assert_eq!(node.pool().ready().count(), 3);

// // Ensure tx priority order:
// // Inherent -> Operational tx -> Unsigned tx -> Signed normal tx
// let mut txs = node.pool().ready();
// let tx1 = txs.next().unwrap();
// let tx2 = txs.next().unwrap();
// let tx3 = txs.next().unwrap();

// assert_eq!(tx1.hash, operational_tx_hash);
// assert_eq!(tx1.priority, 13835064928601523711);

// assert_eq!(tx2.hash, unsigned_tx_hash);
// assert_eq!(tx2.priority, 1844674407370965161);

// assert_eq!(tx3.hash, normal_tx_hash);
// assert_eq!(tx3.priority, 42785501349000);
// })
// }
}
Loading