mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Add documentation to SubmitSignedTransaction and actually make it work (#4200)
* Add documentation to signed transactions and actually make them work. * Fix naming and bounds. * Forgotten import. * Remove warning. * Make accounts optional, fix logic. * Split the method to avoid confusing type error message. * Move executor tests to integration. * Add submit transactions tests. * Make `submit_transaction` tests compile * Remove a file that was accidently committed * Add can_sign helper function. * Fix compilation. * Add a key to keystore. * Fix the tests. * Remove env_logger. * Fix sending multiple transactions. * Remove commented code. * Bring back criterion. * Remove stray debug log. * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Make sure to initialize block correctly. * Initialize block for offchain workers. * Add test for transaction validity. * Fix tests. * Review suggestions. * Remove redundant comment. * Make sure to use correct block number of authoring. * Change the runtime API. * Support both versions. * Bump spec version, fix RPC test. Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: Gavin Wood <github@gavwood.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
Gavin Wood
parent
a1e0076aa8
commit
74d6e660c6
@@ -861,6 +861,16 @@ fn storage_size() {
|
||||
});
|
||||
}
|
||||
|
||||
fn initialize_block(number: u64) {
|
||||
System::initialize(
|
||||
&number,
|
||||
&[0u8; 32].into(),
|
||||
&[0u8; 32].into(),
|
||||
&Default::default(),
|
||||
Default::default(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deduct_blocks() {
|
||||
let (wasm, code_hash) = compile_module::<Test>(CODE_SET_RENT).unwrap();
|
||||
@@ -881,7 +891,7 @@ fn deduct_blocks() {
|
||||
assert_eq!(bob_contract.rent_allowance, 1_000);
|
||||
|
||||
// Advance 4 blocks
|
||||
System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(5);
|
||||
|
||||
// Trigger rent through call
|
||||
assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null()));
|
||||
@@ -896,7 +906,7 @@ fn deduct_blocks() {
|
||||
assert_eq!(Balances::free_balance(BOB), 30_000 - rent);
|
||||
|
||||
// Advance 7 blocks more
|
||||
System::initialize(&12, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(12);
|
||||
|
||||
// Trigger rent through call
|
||||
assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null()));
|
||||
@@ -971,7 +981,7 @@ fn claim_surcharge(blocks: u64, trigger_call: impl Fn() -> bool, removes: bool)
|
||||
));
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&blocks, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(blocks);
|
||||
|
||||
// Trigger rent through call
|
||||
assert!(trigger_call());
|
||||
@@ -1011,7 +1021,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
assert_eq!(Balances::free_balance(&BOB), 100);
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(10);
|
||||
|
||||
// Trigger rent through call
|
||||
assert!(trigger_call());
|
||||
@@ -1019,7 +1029,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
assert_eq!(Balances::free_balance(&BOB), subsistence_threshold);
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(20);
|
||||
|
||||
// Trigger rent must have no effect
|
||||
assert!(trigger_call());
|
||||
@@ -1045,7 +1055,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
assert_eq!(Balances::free_balance(&BOB), 1_000);
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(10);
|
||||
|
||||
// Trigger rent through call
|
||||
assert!(trigger_call());
|
||||
@@ -1054,7 +1064,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
assert_eq!(Balances::free_balance(&BOB), 900);
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(20);
|
||||
|
||||
// Trigger rent must have no effect
|
||||
assert!(trigger_call());
|
||||
@@ -1085,7 +1095,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
assert_eq!(Balances::free_balance(&BOB), Balances::minimum_balance());
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(10);
|
||||
|
||||
// Trigger rent through call
|
||||
assert!(trigger_call());
|
||||
@@ -1093,7 +1103,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
assert_eq!(Balances::free_balance(&BOB), Balances::minimum_balance());
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&20, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(20);
|
||||
|
||||
// Trigger rent must have no effect
|
||||
assert!(trigger_call());
|
||||
@@ -1122,7 +1132,7 @@ fn call_removed_contract() {
|
||||
assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null()));
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&10, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(10);
|
||||
|
||||
// Calling contract should remove contract and fail.
|
||||
assert_err!(
|
||||
@@ -1209,7 +1219,7 @@ fn default_rent_allowance_on_instantiate() {
|
||||
assert_eq!(bob_contract.rent_allowance, <BalanceOf<Test>>::max_value());
|
||||
|
||||
// Advance blocks
|
||||
System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(5);
|
||||
|
||||
// Trigger rent through call
|
||||
assert_ok!(Contract::call(Origin::signed(ALICE), BOB, 0, 100_000, call::null()));
|
||||
@@ -1355,7 +1365,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
|
||||
}
|
||||
|
||||
// Advance 4 blocks, to the 5th.
|
||||
System::initialize(&5, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(5);
|
||||
|
||||
// Call `BOB`, which makes it pay rent. Since the rent allowance is set to 0
|
||||
// we expect that it will get removed leaving tombstone.
|
||||
@@ -1384,7 +1394,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
|
||||
|
||||
if !test_restore_to_with_dirty_storage {
|
||||
// Advance 1 block, to the 6th.
|
||||
System::initialize(&6, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default());
|
||||
initialize_block(6);
|
||||
}
|
||||
|
||||
// Perform a call to `DJANGO`. This should either perform restoration successfully or
|
||||
|
||||
Reference in New Issue
Block a user