Skip to content

Commit

Permalink
Update all tests to an Albatross network ID
Browse files Browse the repository at this point in the history
Most tests still used the NetworkId::Dummy, which is not an Albatross ID, so doesn't include sender_data into a transaction's serialized_content, thus not testing the whole Albatross range.
  • Loading branch information
sisou committed Aug 16, 2024
1 parent e227c16 commit ddf9d36
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion blockchain/src/history/history_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ mod tests {
Coin::from_u64_unchecked(value),
Coin::from_u64_unchecked(0),
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
)),
}
Expand Down
2 changes: 1 addition & 1 deletion blockchain/src/history/history_store_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ mod tests {
Coin::from_u64_unchecked(value),
Coin::from_u64_unchecked(0),
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
)),
}
Expand Down
2 changes: 1 addition & 1 deletion genesis-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Default for GenesisBuilder {
impl GenesisBuilder {
fn new_without_defaults() -> Self {
GenesisBuilder {
network: NetworkId::Dummy,
network: NetworkId::UnitAlbatross,
timestamp: None,
vrf_seed: None,
parent_election_hash: None,
Expand Down
4 changes: 2 additions & 2 deletions primitives/account/tests/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ fn it_commits_valid_and_failing_txns() {
2000.try_into().unwrap(),
200.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);
tx.sender_type = AccountType::Vesting;

Expand Down Expand Up @@ -847,7 +847,7 @@ fn it_commits_valid_and_failing_txns() {
2000.try_into().unwrap(),
200.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);
// tx.sender_type = AccountType::Basic;

Expand Down
6 changes: 3 additions & 3 deletions primitives/account/tests/staking_contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn make_incoming_transaction(data: IncomingStakingTransactionData, value: u64) -
value.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
_ => Transaction::new_signaling(
non_existent_address(),
Expand All @@ -95,7 +95,7 @@ fn make_incoming_transaction(data: IncomingStakingTransactionData, value: u64) -
100.try_into().unwrap(),
data.serialize_to_vec(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ fn make_delete_validator_transaction() -> Transaction {
(Policy::VALIDATOR_DEPOSIT - 100).try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

let private_key =
Expand Down
2 changes: 1 addition & 1 deletion primitives/account/tests/staking_contract/staker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn make_remove_stake_transaction_with_fee(value: u64, fee: u64) -> Transaction {
value.try_into().unwrap(),
fee.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

let private_key =
Expand Down
4 changes: 2 additions & 2 deletions primitives/transaction/tests/basic_account_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn it_does_not_allow_creation() {
100.try_into().unwrap(),
0.try_into().unwrap(),
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

assert_eq!(
Expand All @@ -36,7 +36,7 @@ fn it_does_not_allow_signalling() {
0.try_into().unwrap(),
vec![],
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

assert_eq!(
Expand Down
30 changes: 15 additions & 15 deletions primitives/transaction/tests/staking_contract_verify.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test-utils/src/performance/history-store/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn create_transaction(block: u32, value: u64) -> HistoricTransaction {
Coin::from_u64_unchecked(value),
Coin::from_u64_unchecked(0),
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
)),
}
Expand Down
12 changes: 6 additions & 6 deletions transaction-builder/tests/htlc_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn it_can_create_creation_transaction() {
100.try_into().unwrap(),
0.try_into().unwrap(),
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

let mut htlc_builder = Recipient::new_htlc_builder();
Expand All @@ -52,7 +52,7 @@ fn it_can_create_creation_transaction() {
.with_recipient(htlc_builder.generate().unwrap())
.with_value(100.try_into().unwrap())
.with_validity_start_height(0)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let result = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down Expand Up @@ -100,7 +100,7 @@ fn prepare_outgoing_transaction() -> (
1000.try_into().unwrap(),
0.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

let sender_signature = sender_key_pair.sign(&tx.serialize_content()[..]);
Expand Down Expand Up @@ -142,7 +142,7 @@ fn it_can_create_regular_transfer() {
.with_value(1000.try_into().unwrap())
.with_fee(0.try_into().unwrap())
.with_validity_start_height(1)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down Expand Up @@ -182,7 +182,7 @@ fn it_can_create_early_resolve() {
.with_value(1000.try_into().unwrap())
.with_fee(0.try_into().unwrap())
.with_validity_start_height(1)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down Expand Up @@ -215,7 +215,7 @@ fn it_can_create_timeout_resolve() {
.with_value(1000.try_into().unwrap())
.with_fee(0.try_into().unwrap())
.with_validity_start_height(1)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down
30 changes: 15 additions & 15 deletions transaction-builder/tests/staking_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn it_can_create_staker_transactions() {
100_000_000.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand All @@ -61,7 +61,7 @@ fn it_can_create_staker_transactions() {
100_000_000.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand All @@ -85,7 +85,7 @@ fn it_can_create_staker_transactions() {
false,
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand All @@ -98,7 +98,7 @@ fn it_can_create_staker_transactions() {
false,
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand All @@ -113,7 +113,7 @@ fn it_can_create_staker_transactions() {
150_000_000.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand All @@ -132,7 +132,7 @@ fn it_can_fail_creating_staker_transactions() {
0.try_into().unwrap(), // InvalidValue
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.err();

Expand Down Expand Up @@ -172,7 +172,7 @@ fn it_can_create_validator_transactions() {
Some(Blake2bHash::default()),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand Down Expand Up @@ -201,7 +201,7 @@ fn it_can_create_validator_transactions() {
None,
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

assert_eq!(tx, tx2);
Expand All @@ -222,7 +222,7 @@ fn it_can_create_validator_transactions() {
&key_pair,
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

assert_eq!(tx, tx2);
Expand All @@ -243,7 +243,7 @@ fn it_can_create_validator_transactions() {
&key_pair,
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

assert_eq!(tx, tx2);
Expand All @@ -257,7 +257,7 @@ fn it_can_create_validator_transactions() {
100.try_into().unwrap(),
Coin::from_u64_unchecked(Policy::VALIDATOR_DEPOSIT - 100),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
)
.unwrap();

Expand All @@ -278,7 +278,7 @@ fn make_incoming_transaction(data: IncomingStakingTransactionData, value: u64) -
value.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
_ => Transaction::new_signaling(
Address::from_any_str(ADDRESS).unwrap(),
Expand All @@ -288,7 +288,7 @@ fn make_incoming_transaction(data: IncomingStakingTransactionData, value: u64) -
100.try_into().unwrap(),
data.serialize_to_vec(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
),
}
}
Expand Down Expand Up @@ -322,7 +322,7 @@ fn make_remove_stake_transaction(key_pair: &KeyPair, value: u64) -> Transaction
value.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);
tx.proof = key_pair.sign(&tx.serialize_content()).serialize_to_vec();
tx
Expand All @@ -340,7 +340,7 @@ fn make_delete_transaction(key_pair: &KeyPair, value: u64) -> Transaction {
value.try_into().unwrap(),
100.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);
tx.proof = key_pair.sign(&tx.serialize_content()).serialize_to_vec();
tx
Expand Down
12 changes: 6 additions & 6 deletions transaction-builder/tests/vesting_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn it_can_create_creation_transaction() {
100.try_into().unwrap(),
0.try_into().unwrap(),
0,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

// Valid
Expand All @@ -38,7 +38,7 @@ fn it_can_create_creation_transaction() {
.with_recipient(recipient.generate().unwrap())
.with_value(100.try_into().unwrap())
.with_validity_start_height(0)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down Expand Up @@ -68,7 +68,7 @@ fn it_can_create_creation_transaction() {
.with_recipient(recipient.generate().unwrap())
.with_value(100.try_into().unwrap())
.with_validity_start_height(0)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down Expand Up @@ -98,7 +98,7 @@ fn it_can_create_creation_transaction() {
.with_recipient(recipient.generate().unwrap())
.with_value(100.try_into().unwrap())
.with_validity_start_height(0)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand All @@ -120,7 +120,7 @@ fn it_can_create_outgoing_transactions() {
1.try_into().unwrap(),
1000.try_into().unwrap(),
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);
tx.sender_type = AccountType::Vesting;

Expand All @@ -135,7 +135,7 @@ fn it_can_create_outgoing_transactions() {
.with_value(1.try_into().unwrap())
.with_fee(1000.try_into().unwrap())
.with_validity_start_height(1)
.with_network_id(NetworkId::Dummy);
.with_network_id(NetworkId::UnitAlbatross);
let proof_builder = builder
.generate()
.expect("Builder should be able to create transaction");
Expand Down
4 changes: 2 additions & 2 deletions wallet/tests/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn it_can_create_valid_transactions() {
Coin::from_u64_unchecked(1),
Coin::ZERO,
1,
NetworkId::Dummy,
NetworkId::UnitAlbatross,
);

let data1 = CommitmentsBuilder::with_private_commitments(kp1.public, commitment_pairs1)
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn it_can_create_valid_transactions() {
)
.unwrap();

assert!(tx.verify(NetworkId::Dummy).is_ok())
assert!(tx.verify(NetworkId::UnitAlbatross).is_ok())
}

#[test]
Expand Down

0 comments on commit ddf9d36

Please sign in to comment.