@@ -127,6 +127,7 @@ impl ExtBuilder {
127
127
balances : vec ! [ ] ,
128
128
intentions : vec ! [ ] ,
129
129
validator_count : 2 ,
130
+ minimum_validator_count : 0 ,
130
131
bonding_duration : 0 ,
131
132
transaction_base_fee : 0 ,
132
133
transaction_byte_fee : 0 ,
@@ -136,6 +137,7 @@ impl ExtBuilder {
136
137
reclaim_rebate : 0 ,
137
138
early_era_slash : 0 ,
138
139
session_reward : 0 ,
140
+ offline_slash_grace : 0 ,
139
141
} . build_storage ( )
140
142
. unwrap ( ) ,
141
143
) ;
@@ -159,13 +161,6 @@ impl ExtBuilder {
159
161
}
160
162
}
161
163
162
- fn new_test_ext ( existential_deposit : u64 , gas_price : u64 ) -> runtime_io:: TestExternalities < KeccakHasher > {
163
- ExtBuilder :: default ( )
164
- . existential_deposit ( existential_deposit)
165
- . gas_price ( gas_price)
166
- . build ( )
167
- }
168
-
169
164
const CODE_TRANSFER : & str = r#"
170
165
(module
171
166
;; ext_transfer(transfer_to: u32, transfer_to_len: u32, value_ptr: u32, value_len: u32)
@@ -195,7 +190,7 @@ fn contract_transfer() {
195
190
196
191
let code_transfer = wabt:: wat2wasm ( CODE_TRANSFER ) . unwrap ( ) ;
197
192
198
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
193
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
199
194
<CodeOf < Test > >:: insert ( 1 , code_transfer. to_vec ( ) ) ;
200
195
201
196
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
@@ -230,7 +225,7 @@ fn contract_transfer_oog() {
230
225
231
226
let code_transfer = wabt:: wat2wasm ( CODE_TRANSFER ) . unwrap ( ) ;
232
227
233
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
228
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
234
229
<CodeOf < Test > >:: insert ( 1 , code_transfer. to_vec ( ) ) ;
235
230
236
231
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
@@ -262,7 +257,7 @@ fn contract_transfer_max_depth() {
262
257
263
258
let code_transfer = wabt:: wat2wasm ( CODE_TRANSFER ) . unwrap ( ) ;
264
259
265
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
260
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
266
261
<CodeOf < Test > >:: insert ( CONTRACT_SHOULD_TRANSFER_TO , code_transfer. to_vec ( ) ) ;
267
262
268
263
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
@@ -362,7 +357,7 @@ fn contract_create() {
362
357
let code_ctor_transfer = wabt:: wat2wasm ( & code_ctor ( & code_transfer) ) . unwrap ( ) ;
363
358
let code_create = wabt:: wat2wasm ( & code_create ( & code_ctor_transfer) ) . unwrap ( ) ;
364
359
365
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
360
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
366
361
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
367
362
Staking :: increase_total_stake_by ( 100_000_000 ) ;
368
363
Staking :: set_free_balance ( & 1 , 0 ) ;
@@ -411,7 +406,7 @@ fn top_level_create() {
411
406
let code_transfer = wabt:: wat2wasm ( CODE_TRANSFER ) . unwrap ( ) ;
412
407
let code_ctor_transfer = wabt:: wat2wasm ( & code_ctor ( & code_transfer) ) . unwrap ( ) ;
413
408
414
- with_externalities ( & mut new_test_ext ( 0 , 3 ) , || {
409
+ with_externalities ( & mut ExtBuilder :: default ( ) . gas_price ( 3 ) . build ( ) , || {
415
410
let derived_address = <Test as Trait >:: DetermineContractAddress :: contract_address_for (
416
411
& code_ctor_transfer,
417
412
& 0 ,
@@ -456,7 +451,7 @@ const CODE_NOP: &'static str = r#"
456
451
fn refunds_unused_gas ( ) {
457
452
let code_nop = wabt:: wat2wasm ( CODE_NOP ) . unwrap ( ) ;
458
453
459
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
454
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
460
455
<CodeOf < Test > >:: insert ( 1 , code_nop. to_vec ( ) ) ;
461
456
462
457
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
@@ -470,7 +465,7 @@ fn refunds_unused_gas() {
470
465
471
466
#[ test]
472
467
fn call_with_zero_value ( ) {
473
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
468
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
474
469
<CodeOf < Test > >:: insert ( 1 , vec ! [ ] ) ;
475
470
476
471
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
@@ -486,7 +481,7 @@ fn call_with_zero_value() {
486
481
fn create_with_zero_endowment ( ) {
487
482
let code_nop = wabt:: wat2wasm ( CODE_NOP ) . unwrap ( ) ;
488
483
489
- with_externalities ( & mut new_test_ext ( 0 , 2 ) , || {
484
+ with_externalities ( & mut ExtBuilder :: default ( ) . build ( ) , || {
490
485
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
491
486
Staking :: increase_total_stake_by ( 100_000_000 ) ;
492
487
@@ -503,42 +498,45 @@ fn create_with_zero_endowment() {
503
498
504
499
#[ test]
505
500
fn account_removal_removes_storage ( ) {
506
- with_externalities ( & mut new_test_ext ( 100 , 2 ) , || {
507
- // Setup two accounts with free balance above than exsistential threshold.
508
- {
509
- Staking :: set_free_balance ( & 1 , 110 ) ;
510
- Staking :: increase_total_stake_by ( 110 ) ;
511
- <StorageOf < Test > >:: insert ( 1 , b"foo" . to_vec ( ) , b"1" . to_vec ( ) ) ;
512
- <StorageOf < Test > >:: insert ( 1 , b"bar" . to_vec ( ) , b"2" . to_vec ( ) ) ;
513
-
514
- Staking :: set_free_balance ( & 2 , 110 ) ;
515
- Staking :: increase_total_stake_by ( 110 ) ;
516
- <StorageOf < Test > >:: insert ( 2 , b"hello" . to_vec ( ) , b"3" . to_vec ( ) ) ;
517
- <StorageOf < Test > >:: insert ( 2 , b"world" . to_vec ( ) , b"4" . to_vec ( ) ) ;
518
- }
519
-
520
- // Transfer funds from account 1 of such amount that after this transfer
521
- // the balance of account 1 is will be below than exsistential threshold.
522
- //
523
- // This should lead to the removal of all storage associated with this account.
524
- assert_ok ! ( Staking :: transfer( & 1 , 2 . into( ) , 20 ) ) ;
525
-
526
- // Verify that all entries from account 1 is removed, while
527
- // entries from account 2 is in place.
528
- {
529
- assert_eq ! ( <StorageOf <Test >>:: get( 1 , b"foo" . to_vec( ) ) , None ) ;
530
- assert_eq ! ( <StorageOf <Test >>:: get( 1 , b"bar" . to_vec( ) ) , None ) ;
531
-
532
- assert_eq ! (
533
- <StorageOf <Test >>:: get( 2 , b"hello" . to_vec( ) ) ,
534
- Some ( b"3" . to_vec( ) )
535
- ) ;
536
- assert_eq ! (
537
- <StorageOf <Test >>:: get( 2 , b"world" . to_vec( ) ) ,
538
- Some ( b"4" . to_vec( ) )
539
- ) ;
540
- }
541
- } ) ;
501
+ with_externalities (
502
+ & mut ExtBuilder :: default ( ) . existential_deposit ( 100 ) . build ( ) ,
503
+ || {
504
+ // Setup two accounts with free balance above than exsistential threshold.
505
+ {
506
+ Staking :: set_free_balance ( & 1 , 110 ) ;
507
+ Staking :: increase_total_stake_by ( 110 ) ;
508
+ <StorageOf < Test > >:: insert ( 1 , b"foo" . to_vec ( ) , b"1" . to_vec ( ) ) ;
509
+ <StorageOf < Test > >:: insert ( 1 , b"bar" . to_vec ( ) , b"2" . to_vec ( ) ) ;
510
+
511
+ Staking :: set_free_balance ( & 2 , 110 ) ;
512
+ Staking :: increase_total_stake_by ( 110 ) ;
513
+ <StorageOf < Test > >:: insert ( 2 , b"hello" . to_vec ( ) , b"3" . to_vec ( ) ) ;
514
+ <StorageOf < Test > >:: insert ( 2 , b"world" . to_vec ( ) , b"4" . to_vec ( ) ) ;
515
+ }
516
+
517
+ // Transfer funds from account 1 of such amount that after this transfer
518
+ // the balance of account 1 is will be below than exsistential threshold.
519
+ //
520
+ // This should lead to the removal of all storage associated with this account.
521
+ assert_ok ! ( Staking :: transfer( & 1 , 2 . into( ) , 20 ) ) ;
522
+
523
+ // Verify that all entries from account 1 is removed, while
524
+ // entries from account 2 is in place.
525
+ {
526
+ assert_eq ! ( <StorageOf <Test >>:: get( 1 , b"foo" . to_vec( ) ) , None ) ;
527
+ assert_eq ! ( <StorageOf <Test >>:: get( 1 , b"bar" . to_vec( ) ) , None ) ;
528
+
529
+ assert_eq ! (
530
+ <StorageOf <Test >>:: get( 2 , b"hello" . to_vec( ) ) ,
531
+ Some ( b"3" . to_vec( ) )
532
+ ) ;
533
+ assert_eq ! (
534
+ <StorageOf <Test >>:: get( 2 , b"world" . to_vec( ) ) ,
535
+ Some ( b"4" . to_vec( ) )
536
+ ) ;
537
+ }
538
+ } ,
539
+ ) ;
542
540
}
543
541
544
542
const CODE_UNREACHABLE : & ' static str = r#"
@@ -553,7 +551,7 @@ const CODE_UNREACHABLE: &'static str = r#"
553
551
#[ test]
554
552
fn top_level_call_refunds_even_if_fails ( ) {
555
553
let code_unreachable = wabt:: wat2wasm ( CODE_UNREACHABLE ) . unwrap ( ) ;
556
- with_externalities ( & mut new_test_ext ( 0 , 4 ) , || {
554
+ with_externalities ( & mut ExtBuilder :: default ( ) . gas_price ( 4 ) . build ( ) , || {
557
555
<CodeOf < Test > >:: insert ( 1 , code_unreachable. to_vec ( ) ) ;
558
556
559
557
Staking :: set_free_balance ( & 0 , 100_000_000 ) ;
0 commit comments