Skip to content

Commit d861b49

Browse files
fix(dpp): use DIP-0002 version 3 in asset-lock tx fixtures (#3621)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c7cb8e6 commit d861b49

7 files changed

Lines changed: 91 additions & 78 deletions

File tree

packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ mod tests {
295295
fn test_transaction_accessor() {
296296
let proof = raw_instant_asset_lock_proof_fixture(None, None);
297297
let tx = proof.transaction();
298-
assert_eq!(tx.version, 0);
298+
// DIP-0002 special transactions (AssetLock) use version 3.
299+
assert_eq!(tx.version, 3);
299300
assert_eq!(tx.lock_time, 0);
300301
assert_eq!(tx.input.len(), 1);
301302
}

packages/rs-dpp/src/identity/state_transition/asset_lock_proof/validate_asset_lock_transaction_structure/v0/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ mod tests {
107107
});
108108

109109
Transaction {
110-
version: 0,
110+
version: 3,
111111
lock_time: 0,
112112
input: inputs,
113113
output: vec![burn_output],

packages/rs-dpp/src/tests/fixtures/instant_asset_lock_proof_fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn instant_asset_lock_proof_transaction_fixture(
9898
});
9999

100100
Transaction {
101-
version: 0,
101+
version: 3,
102102
lock_time: 0,
103103
input: vec![input],
104104
output: vec![burn_output, change_output],

packages/rs-drive-abci/tests/strategy_tests/test_cases/identity_and_document_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ mod tests {
346346
.unwrap()
347347
.unwrap()
348348
),
349-
"975735252c11cea7ef3fbba86928077e37ebe1926972e6ae38e237ce0864100c".to_string()
349+
"9d8167b295676ae3ca225170535c043fd8c5c919394ea708247206553a46cbed".to_string()
350350
)
351351
}
352352

packages/rs-drive-abci/tests/strategy_tests/test_cases/voting_tests.rs

Lines changed: 82 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -585,27 +585,29 @@ mod tests {
585585

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

588-
let first_contender = contenders.first().unwrap();
589-
590-
let second_contender = contenders.last().unwrap();
588+
// Look up by identity id rather than vec position — see explanatory
589+
// comment in the abstain-only test below.
590+
let identity1_contender = contenders
591+
.iter()
592+
.find(|c| c.identifier == identity1_id.to_vec())
593+
.expect("identity1 in contenders");
594+
let identity2_contender = contenders
595+
.iter()
596+
.find(|c| c.identifier == identity2_id.to_vec())
597+
.expect("identity2 in contenders");
591598

592599
assert_eq!(
593-
first_contender.document.as_ref().map(hex::encode),
594-
Some("00177f2479090a0286a67d6a1f67b563b51518edd6eea0461829f7d630fd65708d29124be7e86f97e959894a67a9cc078c3e0106d4bfcfbf34bc403a4f099925b401000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d00046461736800210129124be7e86f97e959894a67a9cc078c3e0106d4bfcfbf34bc403a4f099925b40101".to_string())
600+
identity1_contender.document.as_ref().map(hex::encode),
601+
Some("0021278016512ff707d45a0aa8893a4b1ba67b08158b31bc2bda11a0addb8ab1f4341e6a8e6c01488a75104a8dbc73501ded5cd23abaf688349a8ab34b1157513201000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d000464617368002101341e6a8e6c01488a75104a8dbc73501ded5cd23abaf688349a8ab34b115751320100".to_string())
595602
);
596603

597604
assert_eq!(
598-
second_contender.document.as_ref().map(hex::encode),
599-
Some("00490e212593a1d3cc6ae17bf107ab9cb465175e7877fcf7d085ed2fce27be11d68b8948a6801501bbe0431e3d994dcf71cf5a2a0939fe51b0e600076199aba4fb01000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d0004646173680021018b8948a6801501bbe0431e3d994dcf71cf5a2a0939fe51b0e600076199aba4fb0100".to_string())
605+
identity2_contender.document.as_ref().map(hex::encode),
606+
Some("0010b1d465b94520e76daf018ee6b2740c871d51b7ce9690f60fc7a4a70f1bfd6f3a3c745d6c4d3b88ea52976eaab80dbaa77258885b7b6d8e1edfd00fed72414a01000700000187690895980000018769089598000001876908959800077175616e74756d077175616e74756d0004646173680021013a3c745d6c4d3b88ea52976eaab80dbaa77258885b7b6d8e1edfd00fed72414a0101".to_string())
600607
);
601608

602-
assert_eq!(first_contender.identifier, identity2_id.to_vec());
603-
604-
assert_eq!(second_contender.identifier, identity1_id.to_vec());
605-
606-
assert_eq!(first_contender.vote_count, Some(0));
607-
608-
assert_eq!(second_contender.vote_count, Some(0));
609+
assert_eq!(identity1_contender.vote_count, Some(0));
610+
assert_eq!(identity2_contender.vote_count, Some(0));
609611
}
610612

611613
#[stack_size(STACK_SIZE)]
@@ -945,21 +947,23 @@ mod tests {
945947

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

948-
let first_contender = contenders.first().unwrap();
949-
950-
let second_contender = contenders.last().unwrap();
951-
952-
assert!(first_contender.document.is_some());
953-
954-
assert!(second_contender.document.is_some());
950+
// Look up by identity id rather than vec position — contender ordering
951+
// follows identifier sort, which derives from the asset-lock txid and
952+
// shifts whenever the asset-lock fixture's wire format changes.
953+
let identity1_contender = contenders
954+
.iter()
955+
.find(|c| c.identifier == identity1_id.to_vec())
956+
.expect("identity1 in contenders");
957+
let identity2_contender = contenders
958+
.iter()
959+
.find(|c| c.identifier == identity2_id.to_vec())
960+
.expect("identity2 in contenders");
955961

956-
assert_eq!(first_contender.identifier, identity2_id.to_vec());
962+
assert!(identity1_contender.document.is_some());
963+
assert!(identity2_contender.document.is_some());
957964

958-
assert_eq!(second_contender.identifier, identity1_id.to_vec());
959-
960-
assert_eq!(first_contender.vote_count, Some(0));
961-
962-
assert_eq!(second_contender.vote_count, Some(0));
965+
assert_eq!(identity1_contender.vote_count, Some(0));
966+
assert_eq!(identity2_contender.vote_count, Some(0));
963967

964968
assert_eq!(abstain_vote_tally, Some(124));
965969
}
@@ -1306,23 +1310,24 @@ mod tests {
13061310

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

1309-
let first_contender = contenders.first().unwrap();
1310-
1311-
let second_contender = contenders.last().unwrap();
1312-
1313-
assert!(first_contender.document.is_some());
1314-
1315-
assert!(second_contender.document.is_some());
1316-
1317-
assert_eq!(first_contender.identifier, identity2_id.to_vec());
1313+
// Look up by identity id rather than vec position — see explanatory
1314+
// comment in the abstain-only test above.
1315+
let identity1_contender = contenders
1316+
.iter()
1317+
.find(|c| c.identifier == identity1_id.to_vec())
1318+
.expect("identity1 in contenders");
1319+
let identity2_contender = contenders
1320+
.iter()
1321+
.find(|c| c.identifier == identity2_id.to_vec())
1322+
.expect("identity2 in contenders");
13181323

1319-
assert_eq!(second_contender.identifier, identity1_id.to_vec());
1324+
assert!(identity1_contender.document.is_some());
1325+
assert!(identity2_contender.document.is_some());
13201326

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

1323-
assert_eq!(first_contender.vote_count, Some(52));
1324-
1325-
assert_eq!(second_contender.vote_count, Some(56));
1329+
assert_eq!(identity1_contender.vote_count, Some(56));
1330+
assert_eq!(identity2_contender.vote_count, Some(52));
13261331

13271332
assert_eq!(lock_vote_tally, Some(16));
13281333

@@ -1686,19 +1691,21 @@ mod tests {
16861691

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

1689-
let first_contender = contenders.first().unwrap();
1690-
1691-
let second_contender = contenders.last().unwrap();
1692-
1693-
assert_eq!(first_contender.identifier, identity2_id.to_vec());
1694-
1695-
assert_eq!(second_contender.identifier, identity1_id.to_vec());
1694+
// Look up by identity id rather than vec position — see explanatory
1695+
// comment in the abstain-only test above.
1696+
let identity1_contender = contenders
1697+
.iter()
1698+
.find(|c| c.identifier == identity1_id.to_vec())
1699+
.expect("identity1 in contenders");
1700+
let identity2_contender = contenders
1701+
.iter()
1702+
.find(|c| c.identifier == identity2_id.to_vec())
1703+
.expect("identity2 in contenders");
16961704

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

1699-
assert_eq!(first_contender.vote_count, Some(60));
1700-
1701-
assert_eq!(second_contender.vote_count, Some(4));
1707+
assert_eq!(identity1_contender.vote_count, Some(4));
1708+
assert_eq!(identity2_contender.vote_count, Some(60));
17021709

17031710
assert_eq!(lock_vote_tally, Some(4));
17041711

@@ -2086,21 +2093,23 @@ mod tests {
20862093

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

2089-
let first_contender = contenders.first().unwrap();
2090-
2091-
let second_contender = contenders.last().unwrap();
2092-
2093-
assert_eq!(first_contender.identifier, identity2_id.to_vec());
2094-
2095-
assert_eq!(second_contender.identifier, identity1_id.to_vec());
2096+
// Look up by identity id rather than vec position — see explanatory
2097+
// comment in the abstain-only test above.
2098+
let identity1_contender = contenders
2099+
.iter()
2100+
.find(|c| c.identifier == identity1_id.to_vec())
2101+
.expect("identity1 in contenders");
2102+
let identity2_contender = contenders
2103+
.iter()
2104+
.find(|c| c.identifier == identity2_id.to_vec())
2105+
.expect("identity2 in contenders");
20962106

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

20992109
// 19 votes were cast
21002110

2101-
assert_eq!(first_contender.vote_count, Some(60));
2102-
2103-
assert_eq!(second_contender.vote_count, Some(4));
2111+
assert_eq!(identity1_contender.vote_count, Some(4));
2112+
assert_eq!(identity2_contender.vote_count, Some(60));
21042113

21052114
assert_eq!(lock_vote_tally, Some(4));
21062115

@@ -2517,24 +2526,27 @@ mod tests {
25172526

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

2520-
let first_contender = contenders.first().unwrap();
2521-
2522-
let second_contender = contenders.last().unwrap();
2523-
2524-
assert_eq!(first_contender.identifier, identity2_id.to_vec());
2525-
2526-
assert_eq!(second_contender.identifier, identity1_id.to_vec());
2529+
// Look up by identity id rather than vec position — see explanatory
2530+
// comment in the abstain-only test above.
2531+
let identity1_contender = contenders
2532+
.iter()
2533+
.find(|c| c.identifier == identity1_id.to_vec())
2534+
.expect("identity1 in contenders");
2535+
let identity2_contender = contenders
2536+
.iter()
2537+
.find(|c| c.identifier == identity2_id.to_vec())
2538+
.expect("identity2 in contenders");
25272539

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

25302542
assert_eq!(
25312543
(
2532-
first_contender.vote_count,
2533-
second_contender.vote_count,
2544+
identity1_contender.vote_count,
2545+
identity2_contender.vote_count,
25342546
lock_vote_tally,
25352547
abstain_vote_tally
25362548
),
2537-
(Some(64), Some(8), Some(0), Some(0))
2549+
(Some(8), Some(64), Some(0), Some(0))
25382550
);
25392551

25402552
assert_eq!(

packages/rs-drive-abci/tests/strategy_tests/test_cases/withdrawal_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ mod tests {
16661666

16671667
assert_eq!(
16681668
total_credits_balance.total_identity_balances,
1669-
409997575280380
1669+
409997575173840
16701670
); // Around 4100 Dash.
16711671

16721672
assert_eq!(
@@ -2393,7 +2393,7 @@ mod tests {
23932393

23942394
assert_eq!(
23952395
total_credits_balance.total_identity_balances,
2396-
409997575280380
2396+
409997575173840
23972397
); // Around 4100 Dash.
23982398

23992399
assert_eq!(

packages/strategy-tests/src/transitions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub fn instant_asset_lock_proof_transaction_fixture(
221221
});
222222

223223
Transaction {
224-
version: 0,
224+
version: 3,
225225
lock_time: 0,
226226
input: vec![input],
227227
output: vec![burn_output, change_output],
@@ -305,7 +305,7 @@ pub fn instant_asset_lock_proof_transaction_fixture_with_dynamic_amount(
305305
});
306306

307307
Transaction {
308-
version: 0,
308+
version: 3,
309309
lock_time: 0,
310310
input: vec![input],
311311
output: vec![burn_output, change_output],

0 commit comments

Comments
 (0)