Skip to content

Commit

Permalink
Remove useless vec from MessageSignature::from_raw
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed Jan 3, 2025
1 parent 88dfb88 commit a3feee7
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 74 deletions.
5 changes: 1 addition & 4 deletions stackslib/src/burnchains/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,10 +910,7 @@ fn verify_keys_accepted(node: &mut TestBurnchainNode, prev_keys: &[LeaderKeyRegi
}
}

fn verify_commits_accepted(
node: &TestBurnchainNode,
next_block_commits: &[LeaderBlockCommitOp],
) {
fn verify_commits_accepted(node: &TestBurnchainNode, next_block_commits: &[LeaderBlockCommitOp]) {
// all commits accepted
for commit in next_block_commits.iter() {
let tx_opt =
Expand Down
84 changes: 42 additions & 42 deletions stackslib/src/chainstate/stacks/auth.rs

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions stackslib/src/chainstate/stacks/index/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ where
test_debug!("----- END TRIE ------\n");
}

pub fn merkle_test(
s: &mut TrieStorageConnection<BlockHeaderHash>,
path: &[u8],
value: &[u8],
) {
pub fn merkle_test(s: &mut TrieStorageConnection<BlockHeaderHash>, path: &[u8], value: &[u8]) {
let (_, root_hash) = Trie::read_root(s).unwrap();
let triepath = TrieHash::from_bytes(&path[..]).unwrap();

Expand Down
30 changes: 15 additions & 15 deletions stackslib/src/chainstate/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,24 +1165,24 @@ pub mod test {
key_encoding: TransactionPublicKeyEncoding::Uncompressed,
nonce: 123,
tx_fee: 456,
signature: MessageSignature::from_raw(&vec![0xff; 65])
signature: MessageSignature::from_raw(&[0xff; 65])
}),
TransactionSpendingCondition::Singlesig(SinglesigSpendingCondition {
signer: Hash160([0x11; 20]),
hash_mode: SinglesigHashMode::P2PKH,
key_encoding: TransactionPublicKeyEncoding::Compressed,
nonce: 234,
tx_fee: 567,
signature: MessageSignature::from_raw(&vec![0xff; 65])
signature: MessageSignature::from_raw(&[0xff; 65])
}),
TransactionSpendingCondition::Multisig(MultisigSpendingCondition {
signer: Hash160([0x11; 20]),
hash_mode: MultisigHashMode::P2SH,
nonce: 345,
tx_fee: 678,
fields: vec![
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&vec![0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&vec![0xfe; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&[0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&[0xfe; 65])),
TransactionAuthField::PublicKey(PubKey::from_hex("04ef2340518b5867b23598a9cf74611f8b98064f7d55cdb8c107c67b5efcbc5c771f112f919b00a6c6c5f51f7c63e1762fe9fac9b66ec75a053db7f51f4a52712b").unwrap()),
],
signatures_required: 2
Expand All @@ -1193,8 +1193,8 @@ pub mod test {
nonce: 456,
tx_fee: 789,
fields: vec![
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xfe; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xfe; 65])),
TransactionAuthField::PublicKey(PubKey::from_hex("03ef2340518b5867b23598a9cf74611f8b98064f7d55cdb8c107c67b5efcbc5c77").unwrap())
],
signatures_required: 2
Expand All @@ -1205,16 +1205,16 @@ pub mod test {
key_encoding: TransactionPublicKeyEncoding::Compressed,
nonce: 567,
tx_fee: 890,
signature: MessageSignature::from_raw(&vec![0xfe; 65]),
signature: MessageSignature::from_raw(&[0xfe; 65]),
}),
TransactionSpendingCondition::Multisig(MultisigSpendingCondition {
signer: Hash160([0x11; 20]),
hash_mode: MultisigHashMode::P2WSH,
nonce: 678,
tx_fee: 901,
fields: vec![
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xfe; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xfe; 65])),
TransactionAuthField::PublicKey(PubKey::from_hex("03ef2340518b5867b23598a9cf74611f8b98064f7d55cdb8c107c67b5efcbc5c77").unwrap())
],
signatures_required: 2
Expand All @@ -1229,8 +1229,8 @@ pub mod test {
nonce: 678,
tx_fee: 901,
fields: vec![
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xfe; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xfe; 65])),
TransactionAuthField::PublicKey(PubKey::from_hex("03ef2340518b5867b23598a9cf74611f8b98064f7d55cdb8c107c67b5efcbc5c77").unwrap())
],
signatures_required: 2
Expand All @@ -1241,8 +1241,8 @@ pub mod test {
nonce: 345,
tx_fee: 678,
fields: vec![
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&vec![0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&vec![0xfe; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&[0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Uncompressed, MessageSignature::from_raw(&[0xfe; 65])),
TransactionAuthField::PublicKey(PubKey::from_hex("04ef2340518b5867b23598a9cf74611f8b98064f7d55cdb8c107c67b5efcbc5c771f112f919b00a6c6c5f51f7c63e1762fe9fac9b66ec75a053db7f51f4a52712b").unwrap()),
],
signatures_required: 2
Expand All @@ -1253,8 +1253,8 @@ pub mod test {
nonce: 456,
tx_fee: 789,
fields: vec![
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&vec![0xfe; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xff; 65])),
TransactionAuthField::Signature(TransactionPublicKeyEncoding::Compressed, MessageSignature::from_raw(&[0xfe; 65])),
TransactionAuthField::PublicKey(PubKey::from_hex("03ef2340518b5867b23598a9cf74611f8b98064f7d55cdb8c107c67b5efcbc5c77").unwrap())
],
signatures_required: 2
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/clarity_vm/clarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ mod tests {
key_encoding: TransactionPublicKeyEncoding::Compressed,
nonce: 0,
tx_fee: 1,
signature: MessageSignature::from_raw(&vec![0xfe; 65]),
signature: MessageSignature::from_raw(&[0xfe; 65]),
});

let contract = "(define-public (foo) (ok 1))";
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/core/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ fn mempool_db_test_rbf() {
key_encoding: TransactionPublicKeyEncoding::Uncompressed,
nonce: 123,
tx_fee: 456,
signature: MessageSignature::from_raw(&vec![0xff; 65]),
signature: MessageSignature::from_raw(&[0xff; 65]),
});
let stx_address = StacksAddress {
version: 1,
Expand Down
12 changes: 6 additions & 6 deletions stackslib/src/net/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ pub mod test {
burn_stable_block_height: 0x00001111,
burn_stable_block_hash: BurnchainHeaderHash([0x22; 32]),
additional_data: 0x33333333,
signature: MessageSignature::from_raw(&vec![0x44; 65]),
signature: MessageSignature::from_raw(&[0x44; 65]),
payload_len: 0x000007ff,
};
let preamble_bytes: Vec<u8> = vec![
Expand Down Expand Up @@ -2344,7 +2344,7 @@ pub mod test {
let data = StackerDBChunkData {
slot_id: 2,
slot_version: 3,
sig: MessageSignature::from_raw(&vec![0x44; 65]),
sig: MessageSignature::from_raw(&[0x44; 65]),
data: vec![
0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
],
Expand All @@ -2371,7 +2371,7 @@ pub mod test {
let data = StackerDBChunkData {
slot_id: 2,
slot_version: 3,
sig: MessageSignature::from_raw(&vec![0x44; 65]),
sig: MessageSignature::from_raw(&[0x44; 65]),
data: vec![
0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
],
Expand Down Expand Up @@ -2636,7 +2636,7 @@ pub mod test {
StacksMessageType::StackerDBChunk(StackerDBChunkData {
slot_id: 2,
slot_version: 3,
sig: MessageSignature::from_raw(&vec![0x44; 65]),
sig: MessageSignature::from_raw(&[0x44; 65]),
data: vec![0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]
}),
StacksMessageType::StackerDBPushChunk(StackerDBPushChunkData {
Expand All @@ -2645,7 +2645,7 @@ pub mod test {
chunk_data: StackerDBChunkData {
slot_id: 2,
slot_version: 3,
sig: MessageSignature::from_raw(&vec![0x44; 65]),
sig: MessageSignature::from_raw(&[0x44; 65]),
data: vec![0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]
}
}),
Expand Down Expand Up @@ -2734,7 +2734,7 @@ pub mod test {
burn_stable_block_height: 0x00001111,
burn_stable_block_hash: BurnchainHeaderHash([0x22; 32]),
additional_data: 0x33333333,
signature: MessageSignature::from_raw(&vec![0x44; 65]),
signature: MessageSignature::from_raw(&[0x44; 65]),
payload_len: (relayers_bytes.len() + payload_bytes.len()) as u32,
};

Expand Down

0 comments on commit a3feee7

Please sign in to comment.