@@ -502,9 +502,8 @@ mod tests {
502
502
503
503
use std:: { collections:: HashMap , cell:: RefCell } ;
504
504
use srml_support:: { impl_outer_origin, assert_ok, assert_noop, parameter_types} ;
505
- use sr_io:: with_externalities;
506
- use substrate_primitives:: { H256 , Blake2Hasher } ;
507
- use primitives:: parachain:: Info as ParaInfo ;
505
+ use substrate_primitives:: H256 ;
506
+ use primitives:: parachain:: { Info as ParaInfo , Id as ParaId } ;
508
507
// The testing primitives are very useful for avoiding having to work with signatures
509
508
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
510
509
use sr_primitives:: {
@@ -639,6 +638,7 @@ mod tests {
639
638
type Parachains = TestParachains ;
640
639
type LeasePeriod = LeasePeriod ;
641
640
type EndingPeriod = EndingPeriod ;
641
+ type Randomness = RandomnessCollectiveFlip ;
642
642
}
643
643
parameter_types ! {
644
644
pub const SubmissionDeposit : u64 = 1 ;
@@ -658,10 +658,11 @@ mod tests {
658
658
type Slots = slots:: Module < Test > ;
659
659
type Treasury = treasury:: Module < Test > ;
660
660
type Crowdfund = Module < Test > ;
661
+ type RandomnessCollectiveFlip = randomness_collective_flip:: Module < Test > ;
661
662
662
663
// This function basically just builds a genesis storage key/value store according to
663
664
// our desired mockup.
664
- fn new_test_ext ( ) -> sr_io:: TestExternalities < Blake2Hasher > {
665
+ fn new_test_ext ( ) -> sr_io:: TestExternalities {
665
666
let mut t = system:: GenesisConfig :: default ( ) . build_storage :: < Test > ( ) . unwrap ( ) ;
666
667
balances:: GenesisConfig :: < Test > {
667
668
balances : vec ! [ ( 1 , 1000 ) , ( 2 , 2000 ) , ( 3 , 3000 ) , ( 4 , 4000 ) ] ,
@@ -688,7 +689,7 @@ mod tests {
688
689
689
690
#[ test]
690
691
fn basic_setup_works ( ) {
691
- with_externalities ( & mut new_test_ext ( ) , || {
692
+ new_test_ext ( ) . execute_with ( || {
692
693
assert_eq ! ( System :: block_number( ) , 1 ) ;
693
694
assert_eq ! ( Crowdfund :: fund_count( ) , 0 ) ;
694
695
assert_eq ! ( Crowdfund :: funds( 0 ) , None ) ;
@@ -701,7 +702,7 @@ mod tests {
701
702
702
703
#[ test]
703
704
fn create_works ( ) {
704
- with_externalities ( & mut new_test_ext ( ) , || {
705
+ new_test_ext ( ) . execute_with ( || {
705
706
// Now try to create a crowdfund campaign
706
707
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
707
708
assert_eq ! ( Crowdfund :: fund_count( ) , 1 ) ;
@@ -732,7 +733,7 @@ mod tests {
732
733
733
734
#[ test]
734
735
fn create_handles_basic_errors ( ) {
735
- with_externalities ( & mut new_test_ext ( ) , || {
736
+ new_test_ext ( ) . execute_with ( || {
736
737
// Cannot create a crowdfund with bad slots
737
738
assert_noop ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 4 , 1 , 9 ) , "last slot must be greater than first slot" ) ;
738
739
assert_noop ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 5 , 9 ) , "last slot cannot be more then 3 more than first slot" ) ;
@@ -744,7 +745,7 @@ mod tests {
744
745
745
746
#[ test]
746
747
fn contribute_works ( ) {
747
- with_externalities ( & mut new_test_ext ( ) , || {
748
+ new_test_ext ( ) . execute_with ( || {
748
749
// Set up a crowdfund
749
750
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
750
751
assert_eq ! ( Balances :: free_balance( 1 ) , 999 ) ;
@@ -774,7 +775,7 @@ mod tests {
774
775
775
776
#[ test]
776
777
fn contribute_handles_basic_errors ( ) {
777
- with_externalities ( & mut new_test_ext ( ) , || {
778
+ new_test_ext ( ) . execute_with ( || {
778
779
// Cannot contribute to non-existing fund
779
780
assert_noop ! ( Crowdfund :: contribute( Origin :: signed( 1 ) , 0 , 49 ) , "invalid fund index" ) ;
780
781
// Cannot contribute below minimum contribution
@@ -797,7 +798,7 @@ mod tests {
797
798
798
799
#[ test]
799
800
fn fix_deploy_data_works ( ) {
800
- with_externalities ( & mut new_test_ext ( ) , || {
801
+ new_test_ext ( ) . execute_with ( || {
801
802
// Set up a crowdfund
802
803
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
803
804
assert_eq ! ( Balances :: free_balance( 1 ) , 999 ) ;
@@ -819,7 +820,7 @@ mod tests {
819
820
820
821
#[ test]
821
822
fn fix_deploy_data_handles_basic_errors ( ) {
822
- with_externalities ( & mut new_test_ext ( ) , || {
823
+ new_test_ext ( ) . execute_with ( || {
823
824
// Set up a crowdfund
824
825
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
825
826
assert_eq ! ( Balances :: free_balance( 1 ) , 999 ) ;
@@ -862,7 +863,7 @@ mod tests {
862
863
863
864
#[ test]
864
865
fn onboard_works ( ) {
865
- with_externalities ( & mut new_test_ext ( ) , || {
866
+ new_test_ext ( ) . execute_with ( || {
866
867
// Set up a crowdfund
867
868
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
868
869
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -897,7 +898,7 @@ mod tests {
897
898
898
899
#[ test]
899
900
fn onboard_handles_basic_errors ( ) {
900
- with_externalities ( & mut new_test_ext ( ) , || {
901
+ new_test_ext ( ) . execute_with ( || {
901
902
// Set up a crowdfund
902
903
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
903
904
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -934,7 +935,7 @@ mod tests {
934
935
935
936
#[ test]
936
937
fn begin_retirement_works ( ) {
937
- with_externalities ( & mut new_test_ext ( ) , || {
938
+ new_test_ext ( ) . execute_with ( || {
938
939
// Set up a crowdfund
939
940
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
940
941
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -976,7 +977,7 @@ mod tests {
976
977
977
978
#[ test]
978
979
fn begin_retirement_handles_basic_errors ( ) {
979
- with_externalities ( & mut new_test_ext ( ) , || {
980
+ new_test_ext ( ) . execute_with ( || {
980
981
// Set up a crowdfund
981
982
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
982
983
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -1020,7 +1021,7 @@ mod tests {
1020
1021
1021
1022
#[ test]
1022
1023
fn withdraw_works ( ) {
1023
- with_externalities ( & mut new_test_ext ( ) , || {
1024
+ new_test_ext ( ) . execute_with ( || {
1024
1025
// Set up a crowdfund
1025
1026
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
1026
1027
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -1046,7 +1047,7 @@ mod tests {
1046
1047
1047
1048
#[ test]
1048
1049
fn withdraw_handles_basic_errors ( ) {
1049
- with_externalities ( & mut new_test_ext ( ) , || {
1050
+ new_test_ext ( ) . execute_with ( || {
1050
1051
// Set up a crowdfund
1051
1052
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
1052
1053
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -1070,7 +1071,7 @@ mod tests {
1070
1071
1071
1072
#[ test]
1072
1073
fn dissolve_works ( ) {
1073
- with_externalities ( & mut new_test_ext ( ) , || {
1074
+ new_test_ext ( ) . execute_with ( || {
1074
1075
// Set up a crowdfund
1075
1076
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
1076
1077
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -1105,7 +1106,7 @@ mod tests {
1105
1106
1106
1107
#[ test]
1107
1108
fn dissolve_handles_basic_errors ( ) {
1108
- with_externalities ( & mut new_test_ext ( ) , || {
1109
+ new_test_ext ( ) . execute_with ( || {
1109
1110
// Set up a crowdfund
1110
1111
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
1111
1112
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
@@ -1137,7 +1138,7 @@ mod tests {
1137
1138
1138
1139
#[ test]
1139
1140
fn fund_before_auction_works ( ) {
1140
- with_externalities ( & mut new_test_ext ( ) , || {
1141
+ new_test_ext ( ) . execute_with ( || {
1141
1142
// Create a crowdfund before an auction is created
1142
1143
assert_ok ! ( Crowdfund :: create( Origin :: signed( 1 ) , 1000 , 1 , 4 , 9 ) ) ;
1143
1144
// Users can already contribute
@@ -1175,7 +1176,7 @@ mod tests {
1175
1176
1176
1177
#[ test]
1177
1178
fn fund_across_multiple_auctions_works ( ) {
1178
- with_externalities ( & mut new_test_ext ( ) , || {
1179
+ new_test_ext ( ) . execute_with ( || {
1179
1180
// Create an auction
1180
1181
assert_ok ! ( Slots :: new_auction( Origin :: ROOT , 5 , 1 ) ) ;
1181
1182
// Create two competing crowdfunds, with end dates across multiple auctions
0 commit comments