Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ mod tests {
fn test_transaction_accessor() {
let proof = raw_instant_asset_lock_proof_fixture(None, None);
let tx = proof.transaction();
assert_eq!(tx.version, 0);
// DIP-0002 special transactions (AssetLock) use version 3.
assert_eq!(tx.version, 3);
assert_eq!(tx.lock_time, 0);
assert_eq!(tx.input.len(), 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod tests {
});

Transaction {
version: 0,
version: 3,
lock_time: 0,
input: inputs,
output: vec![burn_output],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn instant_asset_lock_proof_transaction_fixture(
});

Transaction {
version: 0,
version: 3,
lock_time: 0,
input: vec![input],
output: vec![burn_output, change_output],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ mod tests {
.unwrap()
.unwrap()
),
"975735252c11cea7ef3fbba86928077e37ebe1926972e6ae38e237ce0864100c".to_string()
"9d8167b295676ae3ca225170535c043fd8c5c919394ea708247206553a46cbed".to_string()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,27 +585,29 @@ mod tests {

assert_eq!(contenders.len(), 2);

let first_contender = contenders.first().unwrap();

let second_contender = contenders.last().unwrap();
// Look up by identity id rather than vec position — see explanatory
// comment in the abstain-only test below.
let identity1_contender = contenders
.iter()
.find(|c| c.identifier == identity1_id.to_vec())
.expect("identity1 in contenders");
let identity2_contender = contenders
.iter()
.find(|c| c.identifier == identity2_id.to_vec())
.expect("identity2 in contenders");

assert_eq!(
first_contender.document.as_ref().map(hex::encode),
Some("00177f2479090a0286a67d6a1f67b563b51518edd6eea0461829f7d630fd65708d29124be7e86f97e959894a67a9cc078c3e0106d4bfcfbf34bc403a4f099925b401000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d00046461736800210129124be7e86f97e959894a67a9cc078c3e0106d4bfcfbf34bc403a4f099925b40101".to_string())
identity1_contender.document.as_ref().map(hex::encode),
Some("0021278016512ff707d45a0aa8893a4b1ba67b08158b31bc2bda11a0addb8ab1f4341e6a8e6c01488a75104a8dbc73501ded5cd23abaf688349a8ab34b1157513201000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d000464617368002101341e6a8e6c01488a75104a8dbc73501ded5cd23abaf688349a8ab34b115751320100".to_string())
);

assert_eq!(
second_contender.document.as_ref().map(hex::encode),
Some("00490e212593a1d3cc6ae17bf107ab9cb465175e7877fcf7d085ed2fce27be11d68b8948a6801501bbe0431e3d994dcf71cf5a2a0939fe51b0e600076199aba4fb01000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d0004646173680021018b8948a6801501bbe0431e3d994dcf71cf5a2a0939fe51b0e600076199aba4fb0100".to_string())
identity2_contender.document.as_ref().map(hex::encode),
Some("0010b1d465b94520e76daf018ee6b2740c871d51b7ce9690f60fc7a4a70f1bfd6f3a3c745d6c4d3b88ea52976eaab80dbaa77258885b7b6d8e1edfd00fed72414a01000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d0004646173680021013a3c745d6c4d3b88ea52976eaab80dbaa77258885b7b6d8e1edfd00fed72414a0101".to_string())
);

assert_eq!(first_contender.identifier, identity2_id.to_vec());

assert_eq!(second_contender.identifier, identity1_id.to_vec());

assert_eq!(first_contender.vote_count, Some(0));

assert_eq!(second_contender.vote_count, Some(0));
assert_eq!(identity1_contender.vote_count, Some(0));
assert_eq!(identity2_contender.vote_count, Some(0));
}

#[stack_size(STACK_SIZE)]
Expand Down Expand Up @@ -945,21 +947,23 @@ mod tests {

assert_eq!(contenders.len(), 2);

let first_contender = contenders.first().unwrap();

let second_contender = contenders.last().unwrap();

assert!(first_contender.document.is_some());

assert!(second_contender.document.is_some());
// Look up by identity id rather than vec position — contender ordering
// follows identifier sort, which derives from the asset-lock txid and
// shifts whenever the asset-lock fixture's wire format changes.
let identity1_contender = contenders
.iter()
.find(|c| c.identifier == identity1_id.to_vec())
.expect("identity1 in contenders");
let identity2_contender = contenders
.iter()
.find(|c| c.identifier == identity2_id.to_vec())
.expect("identity2 in contenders");

assert_eq!(first_contender.identifier, identity2_id.to_vec());
assert!(identity1_contender.document.is_some());
assert!(identity2_contender.document.is_some());

assert_eq!(second_contender.identifier, identity1_id.to_vec());

assert_eq!(first_contender.vote_count, Some(0));

assert_eq!(second_contender.vote_count, Some(0));
assert_eq!(identity1_contender.vote_count, Some(0));
assert_eq!(identity2_contender.vote_count, Some(0));

assert_eq!(abstain_vote_tally, Some(124));
}
Expand Down Expand Up @@ -1306,23 +1310,24 @@ mod tests {

assert_eq!(contenders.len(), 2);

let first_contender = contenders.first().unwrap();

let second_contender = contenders.last().unwrap();

assert!(first_contender.document.is_some());

assert!(second_contender.document.is_some());

assert_eq!(first_contender.identifier, identity2_id.to_vec());
// Look up by identity id rather than vec position — see explanatory
// comment in the abstain-only test above.
let identity1_contender = contenders
.iter()
.find(|c| c.identifier == identity1_id.to_vec())
.expect("identity1 in contenders");
let identity2_contender = contenders
.iter()
.find(|c| c.identifier == identity2_id.to_vec())
.expect("identity2 in contenders");

assert_eq!(second_contender.identifier, identity1_id.to_vec());
assert!(identity1_contender.document.is_some());
assert!(identity2_contender.document.is_some());

// All vote counts are weighted, so for evonodes, these are in multiples of 4

assert_eq!(first_contender.vote_count, Some(52));

assert_eq!(second_contender.vote_count, Some(56));
assert_eq!(identity1_contender.vote_count, Some(56));
assert_eq!(identity2_contender.vote_count, Some(52));

assert_eq!(lock_vote_tally, Some(16));

Expand Down Expand Up @@ -1686,19 +1691,21 @@ mod tests {

assert_eq!(contenders.len(), 2);

let first_contender = contenders.first().unwrap();

let second_contender = contenders.last().unwrap();

assert_eq!(first_contender.identifier, identity2_id.to_vec());

assert_eq!(second_contender.identifier, identity1_id.to_vec());
// Look up by identity id rather than vec position — see explanatory
// comment in the abstain-only test above.
let identity1_contender = contenders
.iter()
.find(|c| c.identifier == identity1_id.to_vec())
.expect("identity1 in contenders");
let identity2_contender = contenders
.iter()
.find(|c| c.identifier == identity2_id.to_vec())
.expect("identity2 in contenders");

// All vote counts are weighted, so for evonodes, these are in multiples of 4

assert_eq!(first_contender.vote_count, Some(60));

assert_eq!(second_contender.vote_count, Some(4));
assert_eq!(identity1_contender.vote_count, Some(4));
assert_eq!(identity2_contender.vote_count, Some(60));

assert_eq!(lock_vote_tally, Some(4));

Expand Down Expand Up @@ -2086,21 +2093,23 @@ mod tests {

assert_eq!(contenders.len(), 2);

let first_contender = contenders.first().unwrap();

let second_contender = contenders.last().unwrap();

assert_eq!(first_contender.identifier, identity2_id.to_vec());

assert_eq!(second_contender.identifier, identity1_id.to_vec());
// Look up by identity id rather than vec position — see explanatory
// comment in the abstain-only test above.
let identity1_contender = contenders
.iter()
.find(|c| c.identifier == identity1_id.to_vec())
.expect("identity1 in contenders");
let identity2_contender = contenders
.iter()
.find(|c| c.identifier == identity2_id.to_vec())
.expect("identity2 in contenders");

// All vote counts are weighted, so for evonodes, these are in multiples of 4

// 19 votes were cast

assert_eq!(first_contender.vote_count, Some(60));

assert_eq!(second_contender.vote_count, Some(4));
assert_eq!(identity1_contender.vote_count, Some(4));
assert_eq!(identity2_contender.vote_count, Some(60));

assert_eq!(lock_vote_tally, Some(4));

Expand Down Expand Up @@ -2517,24 +2526,27 @@ mod tests {

assert_eq!(contenders.len(), 2);

let first_contender = contenders.first().unwrap();

let second_contender = contenders.last().unwrap();

assert_eq!(first_contender.identifier, identity2_id.to_vec());

assert_eq!(second_contender.identifier, identity1_id.to_vec());
// Look up by identity id rather than vec position — see explanatory
// comment in the abstain-only test above.
let identity1_contender = contenders
.iter()
.find(|c| c.identifier == identity1_id.to_vec())
.expect("identity1 in contenders");
let identity2_contender = contenders
.iter()
.find(|c| c.identifier == identity2_id.to_vec())
.expect("identity2 in contenders");

// All vote counts are weighted, so for evonodes, these are in multiples of 4

assert_eq!(
(
first_contender.vote_count,
second_contender.vote_count,
identity1_contender.vote_count,
identity2_contender.vote_count,
lock_vote_tally,
abstain_vote_tally
),
(Some(64), Some(8), Some(0), Some(0))
(Some(8), Some(64), Some(0), Some(0))
);

assert_eq!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ mod tests {

assert_eq!(
total_credits_balance.total_identity_balances,
409997575280380
409997575173840
); // Around 4100 Dash.

assert_eq!(
Expand Down Expand Up @@ -2393,7 +2393,7 @@ mod tests {

assert_eq!(
total_credits_balance.total_identity_balances,
409997575280380
409997575173840
); // Around 4100 Dash.

assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions packages/strategy-tests/src/transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub fn instant_asset_lock_proof_transaction_fixture(
});

Transaction {
version: 0,
version: 3,
lock_time: 0,
input: vec![input],
output: vec![burn_output, change_output],
Expand Down Expand Up @@ -305,7 +305,7 @@ pub fn instant_asset_lock_proof_transaction_fixture_with_dynamic_amount(
});

Transaction {
version: 0,
version: 3,
lock_time: 0,
input: vec![input],
output: vec![burn_output, change_output],
Expand Down
Loading