1
1
use polkadot_core_primitives:: AccountId ;
2
2
use sp_runtime:: {
3
3
generic:: SignedPayload ,
4
- traits:: { Checkable , Lookup , Verify } ,
4
+ traits:: { Applyable , Checkable , Lookup , Verify , StaticLookup , SignedExtension } ,
5
5
transaction_validity:: { InvalidTransaction , TransactionSource , TransactionValidityError } ,
6
6
BuildStorage , KeyTypeId , MultiAddress , MultiSignature ,
7
7
} ;
@@ -31,20 +31,28 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
31
31
#[ test]
32
32
fn test_validate_transaction_exceeded_max_blob_size ( ) {
33
33
new_test_ext ( ) . execute_with ( || {
34
+ // Run a single block of the system in order to set the genesis hash.
35
+ // The storage of `pallet_system` is initialized to hold 0x45... as the genesis
36
+ // hash, so pushing a block with a different hash would overwrite it.
37
+ // This ensures that the `CheckEra` and `CheckGenesis` provide the same
38
+ // `additional_signed` payload data when constructing the transaction (here)
39
+ // as well as validating it in `Runtime::validate_transaction`, which internally
40
+ // calls `System::initialize` (prior to 1.5.0).
41
+ {
42
+ <frame_system:: Pallet < Runtime > >:: initialize (
43
+ & ( frame_system:: Pallet :: < Runtime > :: block_number ( ) + 1 ) ,
44
+ & Hash :: repeat_byte ( 1 ) ,
45
+ & Default :: default ( ) ,
46
+ ) ;
47
+ <frame_system:: Pallet < Runtime > >:: finalize ( ) ;
48
+ }
49
+
34
50
let alice_pair: sr25519:: Pair = sr25519:: Pair :: from_string ( "//Alice" , None )
35
51
. expect ( "Impossible generate Alice AccountId" )
36
52
. into ( ) ;
37
53
38
- // let alice_pair: sr25519::Pair = sr25519::Pair::from_string(
39
- // "celery harvest shield father arm nice target tell regular junk miss belt",
40
- // None,
41
- // )
42
- // .expect("Impossible generate Alice AccountId")
43
- // .into();
44
-
45
54
let alice_account_id: <Runtime as frame_system:: Config >:: AccountId =
46
55
alice_pair. public ( ) . into ( ) ;
47
- //let alice_address = Address::Id(Keyring::Alice.to_account_id());
48
56
let alice_address = Address :: Id ( alice_account_id. clone ( ) ) ;
49
57
50
58
let source = TransactionSource :: External ;
@@ -62,7 +70,7 @@ fn test_validate_transaction_exceeded_max_blob_size() {
62
70
frame_system:: CheckSpecVersion :: < Runtime > :: new ( ) ,
63
71
frame_system:: CheckTxVersion :: < Runtime > :: new ( ) ,
64
72
frame_system:: CheckGenesis :: < Runtime > :: new ( ) ,
65
- frame_system:: CheckEra :: < Runtime > :: from ( sp_runtime:: generic:: Era :: Immortal ) ,
73
+ frame_system:: CheckEra :: < Runtime > :: from ( sp_runtime:: generic:: Era :: immortal ( ) ) ,
66
74
frame_system:: CheckNonce :: < Runtime > :: from ( 0 ) ,
67
75
frame_system:: CheckWeight :: < Runtime > :: new ( ) ,
68
76
pallet_transaction_payment:: ChargeTransactionPayment :: < Runtime > :: from ( 0 ) ,
@@ -71,21 +79,12 @@ fn test_validate_transaction_exceeded_max_blob_size() {
71
79
72
80
let raw_payload = SignedPayload :: new ( runtime_call. clone ( ) , signed_extra. clone ( ) ) . unwrap ( ) ;
73
81
let signature = raw_payload. using_encoded ( |payload| {
74
- //let sig = Keyring::Alice.sign(payload);
75
82
let sig = alice_pair. sign ( payload) ;
76
83
MultiSignature :: Sr25519 ( sig)
77
84
} ) ;
78
85
79
- //let signed = dbg!(lookup.lookup(alice).unwrap()); // Inside UncheckedExtrinsic there is this lookup, maybe here something is wrong
80
- //if !raw_payload
81
- // .using_encoded(|payload| signature.verify(payload, &(alice_account_id.into())))
82
- //{
83
- // panic!("bad proof");
84
- //}
85
- //println!("proof OK");
86
-
87
86
let tx =
88
- UncheckedExtrinsic :: new_signed ( runtime_call, alice_address, signature, signed_extra) ;
87
+ UncheckedExtrinsic :: new_signed ( runtime_call, alice_address. clone ( ) , signature, signed_extra) ;
89
88
90
89
assert_eq ! (
91
90
Err ( TransactionValidityError :: Invalid (
0 commit comments