Skip to content

Commit 32d6f73

Browse files
rphmeierpepyakin
authored andcommitted
work around additional-signed fuckery
1 parent 8bfe09b commit 32d6f73

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

sugondat-chain/runtimes/sugondat-kusama/tests/integration_test.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use polkadot_core_primitives::AccountId;
22
use sp_runtime::{
33
generic::SignedPayload,
4-
traits::{Checkable, Lookup, Verify},
4+
traits::{Applyable, Checkable, Lookup, Verify, StaticLookup, SignedExtension},
55
transaction_validity::{InvalidTransaction, TransactionSource, TransactionValidityError},
66
BuildStorage, KeyTypeId, MultiAddress, MultiSignature,
77
};
@@ -31,20 +31,28 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
3131
#[test]
3232
fn test_validate_transaction_exceeded_max_blob_size() {
3333
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+
3450
let alice_pair: sr25519::Pair = sr25519::Pair::from_string("//Alice", None)
3551
.expect("Impossible generate Alice AccountId")
3652
.into();
3753

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-
4554
let alice_account_id: <Runtime as frame_system::Config>::AccountId =
4655
alice_pair.public().into();
47-
//let alice_address = Address::Id(Keyring::Alice.to_account_id());
4856
let alice_address = Address::Id(alice_account_id.clone());
4957

5058
let source = TransactionSource::External;
@@ -62,7 +70,7 @@ fn test_validate_transaction_exceeded_max_blob_size() {
6270
frame_system::CheckSpecVersion::<Runtime>::new(),
6371
frame_system::CheckTxVersion::<Runtime>::new(),
6472
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()),
6674
frame_system::CheckNonce::<Runtime>::from(0),
6775
frame_system::CheckWeight::<Runtime>::new(),
6876
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(0),
@@ -71,21 +79,12 @@ fn test_validate_transaction_exceeded_max_blob_size() {
7179

7280
let raw_payload = SignedPayload::new(runtime_call.clone(), signed_extra.clone()).unwrap();
7381
let signature = raw_payload.using_encoded(|payload| {
74-
//let sig = Keyring::Alice.sign(payload);
7582
let sig = alice_pair.sign(payload);
7683
MultiSignature::Sr25519(sig)
7784
});
7885

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-
8786
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);
8988

9089
assert_eq!(
9190
Err(TransactionValidityError::Invalid(

0 commit comments

Comments
 (0)