Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
  • Loading branch information
georgepisaltu committed Oct 16, 2024
1 parent 9cec831 commit 8fe9176
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
9 changes: 7 additions & 2 deletions substrate/bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,19 @@ impl BenchKeyring {
None::<()>,
);
let key = self.accounts.get(&signed).expect("Account id not found in keyring");
let signature = payload.using_encoded(|b| key.sign(&blake2_256(b)));
let signature = payload.using_encoded(|b| {
if b.len() > 256 {
key.sign(&blake2_256(b))
} else {
key.sign(b)
}
});
UncheckedExtrinsic {
preamble: Preamble::Signed(
sp_runtime::MultiAddress::Id(signed),
signature,
0,
tx_ext,
EXTRINSIC_FORMAT_VERSION,
),
function: payload.0,
}
Expand Down
12 changes: 10 additions & 2 deletions substrate/bin/node/testing/src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,22 @@ pub fn sign(
metadata_hash,
);
let key = AccountKeyring::from_account_id(&signed).unwrap();
let signature = payload.using_encoded(|b| key.sign(&blake2_256(b))).into();
let signature =
payload
.using_encoded(|b| {
if b.len() > 256 {
key.sign(&blake2_256(b))
} else {
key.sign(b)
}
})
.into();
UncheckedExtrinsic {
preamble: sp_runtime::generic::Preamble::Signed(
sp_runtime::MultiAddress::Id(signed),
signature,
0,
tx_ext,
EXTRINSIC_FORMAT_VERSION,
),
function: payload.0,
}
Expand Down
11 changes: 1 addition & 10 deletions substrate/frame/examples/offchain-worker/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,7 @@ fn should_submit_signed_transaction_on_chain() {
let tx = pool_state.write().transactions.pop().unwrap();
assert!(pool_state.read().transactions.is_empty());
let tx = Extrinsic::decode(&mut &*tx).unwrap();
assert!(matches!(
tx.preamble,
sp_runtime::generic::Preamble::Signed(
0,
(),
0,
(),
sp_runtime::generic::EXTRINSIC_FORMAT_VERSION
)
));
assert!(matches!(tx.preamble, sp_runtime::generic::Preamble::Signed(0, (), 0, (),)));
assert_eq!(tx.function, RuntimeCall::Example(crate::Call::submit_price { price: 15523 }));
});
}
Expand Down

0 comments on commit 8fe9176

Please sign in to comment.