@@ -41,6 +41,7 @@ struct SignerStateTest {
41
41
tx_a : StacksTransaction ,
42
42
tx_b : StacksTransaction ,
43
43
tx_c : StacksTransaction ,
44
+ tx_d : StacksTransaction ,
44
45
}
45
46
46
47
impl SignerStateTest {
@@ -66,48 +67,26 @@ impl SignerStateTest {
66
67
let pk1 = StacksPrivateKey :: random ( ) ;
67
68
let pk2 = StacksPrivateKey :: random ( ) ;
68
69
let pk3 = StacksPrivateKey :: random ( ) ;
70
+ let pk4 = StacksPrivateKey :: random ( ) ;
69
71
70
- let tx_a = StacksTransaction {
72
+ let make_tx = | pk : & StacksPrivateKey , memo : [ u8 ; 34 ] | StacksTransaction {
71
73
version : TransactionVersion :: Testnet ,
72
74
chain_id : 0x80000000 ,
73
- auth : TransactionAuth :: from_p2pkh ( & pk1 ) . unwrap ( ) ,
75
+ auth : TransactionAuth :: from_p2pkh ( pk ) . unwrap ( ) ,
74
76
anchor_mode : TransactionAnchorMode :: Any ,
75
77
post_condition_mode : TransactionPostConditionMode :: Allow ,
76
78
post_conditions : vec ! [ ] ,
77
79
payload : TransactionPayload :: TokenTransfer (
78
80
local_address. clone ( ) . into ( ) ,
79
81
100 ,
80
- TokenTransferMemo ( [ 1u8 ; 34 ] ) ,
82
+ TokenTransferMemo ( memo ) ,
81
83
) ,
82
84
} ;
83
85
84
- let tx_b = StacksTransaction {
85
- version : TransactionVersion :: Testnet ,
86
- chain_id : 0x80000000 ,
87
- auth : TransactionAuth :: from_p2pkh ( & pk2) . unwrap ( ) ,
88
- anchor_mode : TransactionAnchorMode :: Any ,
89
- post_condition_mode : TransactionPostConditionMode :: Allow ,
90
- post_conditions : vec ! [ ] ,
91
- payload : TransactionPayload :: TokenTransfer (
92
- local_address. clone ( ) . into ( ) ,
93
- 200 ,
94
- TokenTransferMemo ( [ 2u8 ; 34 ] ) ,
95
- ) ,
96
- } ;
97
-
98
- let tx_c = StacksTransaction {
99
- version : TransactionVersion :: Testnet ,
100
- chain_id : 0x80000000 ,
101
- auth : TransactionAuth :: from_p2pkh ( & pk3) . unwrap ( ) ,
102
- anchor_mode : TransactionAnchorMode :: Any ,
103
- post_condition_mode : TransactionPostConditionMode :: Allow ,
104
- post_conditions : vec ! [ ] ,
105
- payload : TransactionPayload :: TokenTransfer (
106
- local_address. clone ( ) . into ( ) ,
107
- 300 ,
108
- TokenTransferMemo ( [ 3u8 ; 34 ] ) ,
109
- ) ,
110
- } ;
86
+ let tx_a = make_tx ( & pk1, [ 1u8 ; 34 ] ) ;
87
+ let tx_b = make_tx ( & pk2, [ 2u8 ; 34 ] ) ;
88
+ let tx_c = make_tx ( & pk3, [ 3u8 ; 34 ] ) ;
89
+ let tx_d = make_tx ( & pk4, [ 4u8 ; 34 ] ) ;
111
90
112
91
Self {
113
92
global_eval,
@@ -120,6 +99,7 @@ impl SignerStateTest {
120
99
tx_a,
121
100
tx_b,
122
101
tx_c,
102
+ tx_d,
123
103
}
124
104
}
125
105
@@ -551,35 +531,6 @@ fn determine_global_states_with_tx_replay_set() {
551
531
552
532
#[ test]
553
533
/// Case: One signer has [A,B,C], another has [A,B] - should find common prefix [A,B]
554
- fn test_replay_set_common_prefix_coalescing_demo ( ) {
555
- let mut state_test = SignerStateTest :: new ( 5 ) ;
556
-
557
- // Signers 0, 1: [A,B,C] (40% weight)
558
- state_test. update_signers (
559
- & [ 0 , 1 ] ,
560
- vec ! [
561
- state_test. tx_a. clone( ) ,
562
- state_test. tx_b. clone( ) ,
563
- state_test. tx_c. clone( ) ,
564
- ] ,
565
- ) ;
566
-
567
- // Signers 2, 3, 4: [A,B] (60% weight - should win)
568
- state_test. update_signers (
569
- & [ 2 , 3 , 4 ] ,
570
- vec ! [ state_test. tx_a. clone( ) , state_test. tx_b. clone( ) ] ,
571
- ) ;
572
-
573
- let transactions = state_test. get_global_replay_set ( ) ;
574
-
575
- // Should find common prefix [A,B] since it's the longest prefix with majority support
576
- assert_eq ! ( transactions. len( ) , 2 ) ;
577
- assert_eq ! ( transactions[ 0 ] , state_test. tx_a) ; // Order matters!
578
- assert_eq ! ( transactions[ 1 ] , state_test. tx_b) ;
579
- assert ! ( !transactions. contains( & state_test. tx_c) ) ;
580
- }
581
-
582
- #[ test]
583
534
fn test_replay_set_common_prefix_coalescing ( ) {
584
535
let mut state_test = SignerStateTest :: new ( 5 ) ;
585
536
@@ -698,22 +649,26 @@ fn test_replay_set_order_matters_no_common_prefix() {
698
649
#[ test]
699
650
/// Case: [A,B,C] vs [A,B,D] should find common prefix [A,B]
700
651
fn test_replay_set_partial_prefix_match ( ) {
701
- let mut state_test = SignerStateTest :: new ( 4 ) ;
652
+ let mut state_test = SignerStateTest :: new ( 5 ) ;
702
653
703
- // Signer 0: [A,B,C] (25 % weight - not enough alone )
654
+ // Signer 0, 1 : [A,B,C] (40 % weight)
704
655
state_test. update_signers (
705
- & [ 0 ] ,
656
+ & [ 0 , 1 ] ,
706
657
vec ! [
707
658
state_test. tx_a. clone( ) ,
708
659
state_test. tx_b. clone( ) ,
709
660
state_test. tx_c. clone( ) ,
710
661
] ,
711
662
) ;
712
663
713
- // Signers 1, 2, 3: [A,B] only (75 % weight - above threshold )
664
+ // Signers 2, 3, 4 : [A,B,D] (60 % weight)
714
665
state_test. update_signers (
715
- & [ 1 , 2 , 3 ] ,
716
- vec ! [ state_test. tx_a. clone( ) , state_test. tx_b. clone( ) ] ,
666
+ & [ 2 , 3 , 4 ] ,
667
+ vec ! [
668
+ state_test. tx_a. clone( ) ,
669
+ state_test. tx_b. clone( ) ,
670
+ state_test. tx_d. clone( ) ,
671
+ ] ,
717
672
) ;
718
673
719
674
let transactions = state_test. get_global_replay_set ( ) ;
0 commit comments