mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Further expand clippy workspace lints
Achieves a notable amount of reduced async and clones.
This commit is contained in:
@@ -89,7 +89,7 @@ fn empty_block() {
|
||||
LAST,
|
||||
HashMap::new(),
|
||||
&mut |_, _| None,
|
||||
validators,
|
||||
&validators,
|
||||
commit,
|
||||
unsigned_in_chain,
|
||||
provided_in_chain,
|
||||
@@ -129,7 +129,7 @@ fn duplicate_nonces() {
|
||||
last_nonce += 1;
|
||||
Some(res)
|
||||
},
|
||||
validators.clone(),
|
||||
&validators,
|
||||
commit,
|
||||
unsigned_in_chain,
|
||||
provided_in_chain,
|
||||
|
||||
@@ -44,12 +44,12 @@ fn block_addition() {
|
||||
let genesis = new_genesis();
|
||||
let validators = Arc::new(Validators::new(genesis, vec![]).unwrap());
|
||||
let (db, mut blockchain) = new_blockchain::<SignedTransaction>(genesis, &[]);
|
||||
let block = blockchain.build_block::<N>(validators.clone());
|
||||
let block = blockchain.build_block::<N>(&validators);
|
||||
|
||||
assert_eq!(block.header.parent, genesis);
|
||||
assert_eq!(block.header.transactions, [0; 32]);
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], validators).is_ok());
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], &validators).is_ok());
|
||||
assert_eq!(blockchain.tip(), block.hash());
|
||||
assert_eq!(blockchain.block_number(), 1);
|
||||
assert_eq!(
|
||||
@@ -64,21 +64,21 @@ fn invalid_block() {
|
||||
let validators = Arc::new(Validators::new(genesis, vec![]).unwrap());
|
||||
let (_, mut blockchain) = new_blockchain::<SignedTransaction>(genesis, &[]);
|
||||
|
||||
let block = blockchain.build_block::<N>(validators.clone());
|
||||
let block = blockchain.build_block::<N>(&validators);
|
||||
|
||||
// Mutate parent
|
||||
{
|
||||
#[allow(clippy::redundant_clone)] // False positive
|
||||
let mut block = block.clone();
|
||||
block.header.parent = Blake2s256::digest(block.header.parent).into();
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
}
|
||||
|
||||
// Mutate tranactions merkle
|
||||
{
|
||||
let mut block = block;
|
||||
block.header.transactions = Blake2s256::digest(block.header.transactions).into();
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
}
|
||||
|
||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
||||
@@ -89,7 +89,7 @@ fn invalid_block() {
|
||||
// Manually create the block to bypass build_block's checks
|
||||
let block = Block::new(blockchain.tip(), vec![], vec![Transaction::Application(tx.clone())]);
|
||||
assert_eq!(block.header.transactions, merkle(&[tx.hash()]));
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
}
|
||||
|
||||
// Run the rest of the tests with them as a participant
|
||||
@@ -99,22 +99,22 @@ fn invalid_block() {
|
||||
{
|
||||
let block = Block::new(blockchain.tip(), vec![], vec![Transaction::Application(tx.clone())]);
|
||||
assert_eq!(block.header.transactions, merkle(&[tx.hash()]));
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
}
|
||||
|
||||
{
|
||||
// Add a valid transaction
|
||||
let (_, mut blockchain) = new_blockchain(genesis, &[tx.1.signer]);
|
||||
blockchain
|
||||
.add_transaction::<N>(true, Transaction::Application(tx.clone()), validators.clone())
|
||||
.add_transaction::<N>(true, Transaction::Application(tx.clone()), &validators)
|
||||
.unwrap();
|
||||
let mut block = blockchain.build_block::<N>(validators.clone());
|
||||
let mut block = blockchain.build_block::<N>(&validators);
|
||||
assert_eq!(block.header.transactions, merkle(&[tx.hash()]));
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
|
||||
// And verify mutating the transactions merkle now causes a failure
|
||||
block.header.transactions = merkle(&[]);
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -122,24 +122,22 @@ fn invalid_block() {
|
||||
let tx = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 5);
|
||||
// Manually create the block to bypass build_block's checks
|
||||
let block = Block::new(blockchain.tip(), vec![], vec![Transaction::Application(tx)]);
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
}
|
||||
|
||||
{
|
||||
// Invalid signature
|
||||
let (_, mut blockchain) = new_blockchain(genesis, &[tx.1.signer]);
|
||||
blockchain
|
||||
.add_transaction::<N>(true, Transaction::Application(tx), validators.clone())
|
||||
.unwrap();
|
||||
let mut block = blockchain.build_block::<N>(validators.clone());
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
blockchain.add_transaction::<N>(true, Transaction::Application(tx), &validators).unwrap();
|
||||
let mut block = blockchain.build_block::<N>(&validators);
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
match &mut block.transactions[0] {
|
||||
Transaction::Application(tx) => {
|
||||
tx.1.signature.s += <Ristretto as Ciphersuite>::F::ONE;
|
||||
}
|
||||
_ => panic!("non-signed tx found"),
|
||||
}
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
|
||||
// Make sure this isn't because the merkle changed due to the transaction hash including the
|
||||
// signature (which it explicitly isn't allowed to anyways)
|
||||
@@ -166,12 +164,10 @@ fn signed_transaction() {
|
||||
panic!("tendermint tx found");
|
||||
};
|
||||
let next_nonce = blockchain.next_nonce(&signer, &[]).unwrap();
|
||||
blockchain
|
||||
.add_transaction::<N>(true, Transaction::Application(tx), validators.clone())
|
||||
.unwrap();
|
||||
blockchain.add_transaction::<N>(true, Transaction::Application(tx), &validators).unwrap();
|
||||
assert_eq!(next_nonce + 1, blockchain.next_nonce(&signer, &[]).unwrap());
|
||||
}
|
||||
let block = blockchain.build_block::<N>(validators.clone());
|
||||
let block = blockchain.build_block::<N>(&validators);
|
||||
assert_eq!(block, Block::new(blockchain.tip(), vec![], mempool.clone()));
|
||||
assert_eq!(blockchain.tip(), tip);
|
||||
assert_eq!(block.header.parent, tip);
|
||||
@@ -185,8 +181,8 @@ fn signed_transaction() {
|
||||
);
|
||||
|
||||
// Verify and add the block
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], validators.clone()).is_ok());
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], &validators).is_ok());
|
||||
assert_eq!(blockchain.tip(), block.hash());
|
||||
};
|
||||
|
||||
@@ -233,21 +229,21 @@ fn provided_transaction() {
|
||||
{
|
||||
// Non-provided transactions should fail verification because we don't have them locally.
|
||||
let block = Block::new(blockchain.tip(), vec![tx.clone()], vec![]);
|
||||
assert!(blockchain.verify_block::<N>(&block, validators.clone(), false).is_err());
|
||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||
|
||||
// Provided transactions should pass verification
|
||||
blockchain.provide_transaction(tx.clone()).unwrap();
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
|
||||
// add_block should work for verified blocks
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], validators.clone()).is_ok());
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], &validators).is_ok());
|
||||
|
||||
let block = Block::new(blockchain.tip(), vec![tx.clone()], vec![]);
|
||||
|
||||
// The provided transaction should no longer considered provided but added to chain,
|
||||
// causing this error
|
||||
assert_eq!(
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false),
|
||||
blockchain.verify_block::<N>(&block, &validators, false),
|
||||
Err(BlockError::ProvidedAlreadyIncluded)
|
||||
);
|
||||
}
|
||||
@@ -262,11 +258,11 @@ fn provided_transaction() {
|
||||
// add_block DOES NOT fail for unverified provided transactions if told to add them,
|
||||
// since now we can have them later.
|
||||
let block1 = Block::new(blockchain.tip(), vec![tx1.clone(), tx3.clone()], vec![]);
|
||||
assert!(blockchain.add_block::<N>(&block1, vec![], validators.clone()).is_ok());
|
||||
assert!(blockchain.add_block::<N>(&block1, vec![], &validators).is_ok());
|
||||
|
||||
// in fact, we can have many blocks that have provided txs that we don't have locally.
|
||||
let block2 = Block::new(blockchain.tip(), vec![tx2.clone(), tx4.clone()], vec![]);
|
||||
assert!(blockchain.add_block::<N>(&block2, vec![], validators.clone()).is_ok());
|
||||
assert!(blockchain.add_block::<N>(&block2, vec![], &validators).is_ok());
|
||||
|
||||
// make sure we won't return ok for the block before we actually got the txs
|
||||
let TransactionKind::Provided(order) = tx1.kind() else { panic!("tx wasn't provided") };
|
||||
@@ -357,11 +353,9 @@ async fn tendermint_evidence_tx() {
|
||||
let Transaction::Tendermint(tx) = tx else {
|
||||
panic!("non-tendermint tx found");
|
||||
};
|
||||
blockchain
|
||||
.add_transaction::<N>(true, Transaction::Tendermint(tx), validators.clone())
|
||||
.unwrap();
|
||||
blockchain.add_transaction::<N>(true, Transaction::Tendermint(tx), &validators).unwrap();
|
||||
}
|
||||
let block = blockchain.build_block::<N>(validators.clone());
|
||||
let block = blockchain.build_block::<N>(&validators);
|
||||
assert_eq!(blockchain.tip(), tip);
|
||||
assert_eq!(block.header.parent, tip);
|
||||
|
||||
@@ -371,8 +365,8 @@ async fn tendermint_evidence_tx() {
|
||||
}
|
||||
|
||||
// Verify and add the block
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], validators.clone()).is_ok());
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
assert!(blockchain.add_block::<N>(&block, vec![], &validators).is_ok());
|
||||
assert_eq!(blockchain.tip(), block.hash());
|
||||
};
|
||||
|
||||
@@ -467,7 +461,7 @@ async fn block_tx_ordering() {
|
||||
let signed_tx = Transaction::Application(SignedTx::Signed(Box::new(
|
||||
crate::tests::signed_transaction(&mut OsRng, genesis, &key, i),
|
||||
)));
|
||||
blockchain.add_transaction::<N>(true, signed_tx.clone(), validators.clone()).unwrap();
|
||||
blockchain.add_transaction::<N>(true, signed_tx.clone(), &validators).unwrap();
|
||||
mempool.push(signed_tx);
|
||||
|
||||
let unsigned_tx = Transaction::Tendermint(
|
||||
@@ -477,7 +471,7 @@ async fn block_tx_ordering() {
|
||||
)
|
||||
.await,
|
||||
);
|
||||
blockchain.add_transaction::<N>(true, unsigned_tx.clone(), validators.clone()).unwrap();
|
||||
blockchain.add_transaction::<N>(true, unsigned_tx.clone(), &validators).unwrap();
|
||||
mempool.push(unsigned_tx);
|
||||
|
||||
let provided_tx =
|
||||
@@ -485,7 +479,7 @@ async fn block_tx_ordering() {
|
||||
blockchain.provide_transaction(provided_tx.clone()).unwrap();
|
||||
provided_txs.push(provided_tx);
|
||||
}
|
||||
let block = blockchain.build_block::<N>(validators.clone());
|
||||
let block = blockchain.build_block::<N>(&validators);
|
||||
|
||||
assert_eq!(blockchain.tip(), tip);
|
||||
assert_eq!(block.header.parent, tip);
|
||||
@@ -509,7 +503,7 @@ async fn block_tx_ordering() {
|
||||
}
|
||||
|
||||
// should be a valid block
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap();
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||
|
||||
// Unsigned before Provided
|
||||
{
|
||||
@@ -518,7 +512,7 @@ async fn block_tx_ordering() {
|
||||
let unsigned = block.transactions.remove(128);
|
||||
block.transactions.insert(0, unsigned);
|
||||
assert_eq!(
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap_err(),
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap_err(),
|
||||
BlockError::WrongTransactionOrder
|
||||
);
|
||||
}
|
||||
@@ -529,7 +523,7 @@ async fn block_tx_ordering() {
|
||||
let signed = block.transactions.remove(256);
|
||||
block.transactions.insert(0, signed);
|
||||
assert_eq!(
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap_err(),
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap_err(),
|
||||
BlockError::WrongTransactionOrder
|
||||
);
|
||||
}
|
||||
@@ -539,7 +533,7 @@ async fn block_tx_ordering() {
|
||||
let mut block = block;
|
||||
block.transactions.swap(128, 256);
|
||||
assert_eq!(
|
||||
blockchain.verify_block::<N>(&block, validators.clone(), false).unwrap_err(),
|
||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap_err(),
|
||||
BlockError::WrongTransactionOrder
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ async fn mempool_addition() {
|
||||
&|_, _| Some(0),
|
||||
true,
|
||||
Transaction::Application(first_tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
)
|
||||
@@ -63,7 +63,7 @@ async fn mempool_addition() {
|
||||
&|_, _| None,
|
||||
true,
|
||||
Transaction::Tendermint(evidence_tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
)
|
||||
@@ -78,7 +78,7 @@ async fn mempool_addition() {
|
||||
&|_, _| Some(0),
|
||||
true,
|
||||
Transaction::Application(first_tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
),
|
||||
@@ -89,7 +89,7 @@ async fn mempool_addition() {
|
||||
&|_, _| None,
|
||||
true,
|
||||
Transaction::Tendermint(evidence_tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
),
|
||||
@@ -103,7 +103,7 @@ async fn mempool_addition() {
|
||||
&|_, _| Some(0),
|
||||
true,
|
||||
Transaction::Application(second_tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
),
|
||||
@@ -115,7 +115,7 @@ async fn mempool_addition() {
|
||||
&|_, _| Some(0),
|
||||
true,
|
||||
Transaction::Application(second_tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
),
|
||||
@@ -133,7 +133,7 @@ async fn mempool_addition() {
|
||||
&|_, _| Some(2),
|
||||
true,
|
||||
Transaction::Application(tx.clone()),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit
|
||||
)
|
||||
@@ -173,7 +173,7 @@ fn too_many_mempool() {
|
||||
&|_, _| Some(0),
|
||||
false,
|
||||
Transaction::Application(signed_transaction(&mut OsRng, genesis, &key, i)),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
)
|
||||
@@ -190,7 +190,7 @@ fn too_many_mempool() {
|
||||
&key,
|
||||
ACCOUNT_MEMPOOL_LIMIT
|
||||
)),
|
||||
validators.clone(),
|
||||
&validators,
|
||||
unsigned_in_chain,
|
||||
commit,
|
||||
),
|
||||
|
||||
@@ -57,13 +57,13 @@ async fn invalid_valid_round() {
|
||||
|
||||
// This should be invalid evidence if a valid valid round is specified
|
||||
let (_, tx) = valid_round_tx(None).await;
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
|
||||
// If an invalid valid round is specified (>= current), this should be invalid evidence
|
||||
let (mut signed, tx) = valid_round_tx(Some(RoundNumber(0))).await;
|
||||
|
||||
// should pass
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||
|
||||
// change the signature
|
||||
let mut random_sig = [0u8; 64];
|
||||
@@ -72,7 +72,7 @@ async fn invalid_valid_round() {
|
||||
let tx = TendermintTx::SlashEvidence(Evidence::InvalidValidRound(signed.encode()));
|
||||
|
||||
// should fail
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators, commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -94,7 +94,7 @@ async fn invalid_precommit_signature() {
|
||||
};
|
||||
|
||||
// Empty Precommit should fail.
|
||||
assert!(verify_tendermint_tx::<N>(&precommit(None).await.1, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&precommit(None).await.1, &validators, commit).is_err());
|
||||
|
||||
// valid precommit signature should fail.
|
||||
let block_id = [0x22u8; 32];
|
||||
@@ -105,7 +105,7 @@ async fn invalid_precommit_signature() {
|
||||
|
||||
assert!(verify_tendermint_tx::<N>(
|
||||
&precommit(Some((block_id, signer.clone().sign(&commit_msg).await))).await.1,
|
||||
validators.clone(),
|
||||
&validators,
|
||||
commit
|
||||
)
|
||||
.is_err());
|
||||
@@ -113,14 +113,14 @@ async fn invalid_precommit_signature() {
|
||||
// any other signature can be used as evidence.
|
||||
{
|
||||
let (mut signed, tx) = precommit(Some((block_id, signer.sign(&[]).await))).await;
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||
|
||||
// So long as we can authenticate where it came from
|
||||
let mut random_sig = [0u8; 64];
|
||||
OsRng.fill_bytes(&mut random_sig);
|
||||
signed.sig = random_sig;
|
||||
let tx = TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(signed.encode()));
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators, commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,10 +170,10 @@ async fn evidence_with_prevote() {
|
||||
|
||||
// No prevote message alone should be valid as slash evidence at this time
|
||||
for prevote in prevote(None).await {
|
||||
assert!(verify_tendermint_tx::<N>(&prevote, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&prevote, &validators, commit).is_err());
|
||||
}
|
||||
for prevote in prevote(Some([0x22u8; 32])).await {
|
||||
assert!(verify_tendermint_tx::<N>(&prevote, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&prevote, &validators, commit).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_1.encode(),
|
||||
));
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
|
||||
// conflicting data should pass
|
||||
let signed_2 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
||||
@@ -207,7 +207,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||
|
||||
// Except if it has a distinct round number, as we don't check cross-round conflicts
|
||||
// (except for Precommit)
|
||||
@@ -216,7 +216,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap_err();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||
|
||||
// Proposals for different block numbers should also fail as evidence
|
||||
let signed_2 = signed_for_b_r(1, 0, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
||||
@@ -224,7 +224,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap_err();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||
}
|
||||
|
||||
// Prevote
|
||||
@@ -235,7 +235,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_1.encode(),
|
||||
));
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
|
||||
// conflicting data should pass
|
||||
let signed_2 = signed_for_b_r(0, 0, Data::Prevote(Some([0x22; 32]))).await;
|
||||
@@ -243,7 +243,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||
|
||||
// Except if it has a distinct round number, as we don't check cross-round conflicts
|
||||
// (except for Precommit)
|
||||
@@ -252,7 +252,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap_err();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||
|
||||
// Proposals for different block numbers should also fail as evidence
|
||||
let signed_2 = signed_for_b_r(1, 0, Data::Prevote(Some([0x22; 32]))).await;
|
||||
@@ -260,7 +260,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap_err();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||
}
|
||||
|
||||
// Precommit
|
||||
@@ -272,7 +272,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_1.encode(),
|
||||
));
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
|
||||
// For precommit, the round number is ignored
|
||||
let signed_2 = signed_for_b_r(0, 1, Data::Precommit(Some(([0x22; 32], sig)))).await;
|
||||
@@ -280,7 +280,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
verify_tendermint_tx::<N>(&tx, validators.clone(), commit).unwrap();
|
||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||
|
||||
// Yet the block number isn't
|
||||
let signed_2 = signed_for_b_r(1, 0, Data::Precommit(Some(([0x22; 32], sig)))).await;
|
||||
@@ -288,7 +288,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
}
|
||||
|
||||
// msgs from different senders should fail
|
||||
@@ -320,7 +320,7 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
let validators =
|
||||
Arc::new(Validators::new(genesis, vec![(signer_pub, 1), (signer_pub_2, 1)]).unwrap());
|
||||
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators, commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
}
|
||||
|
||||
// msgs with different steps should fail
|
||||
@@ -331,6 +331,6 @@ async fn conflicting_msgs_evidence_tx() {
|
||||
signed_1.encode(),
|
||||
signed_2.encode(),
|
||||
));
|
||||
assert!(verify_tendermint_tx::<N>(&tx, validators.clone(), commit).is_err());
|
||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user