@@ -188,7 +188,7 @@ type validatorRange struct {
188188
189189// createSnowCtx creates a snow.Context instance with a validator state specified by the given validatorRanges
190190func createSnowCtx (tb testing.TB , validatorRanges []validatorRange ) * snow.Context {
191- getValidatorsOutput := make (map [ids.NodeID ]* validators.GetValidatorOutput )
191+ validatorSet := make (map [ids.NodeID ]* validators.GetValidatorOutput )
192192
193193 for _ , validatorRange := range validatorRanges {
194194 for i := validatorRange .start ; i < validatorRange .end ; i ++ {
@@ -199,20 +199,19 @@ func createSnowCtx(tb testing.TB, validatorRanges []validatorRange) *snow.Contex
199199 if validatorRange .publicKey {
200200 validatorOutput .PublicKey = testVdrs [i ].vdr .PublicKey
201201 }
202- getValidatorsOutput [testVdrs [i ].nodeID ] = validatorOutput
202+ validatorSet [testVdrs [i ].nodeID ] = validatorOutput
203203 }
204204 }
205205
206206 snowCtx := utilstest .NewTestSnowContext (tb )
207- state : = & validatorstest.State {
207+ snowCtx . ValidatorState = & validatorstest.State {
208208 GetSubnetIDF : func (context.Context , ids.ID ) (ids.ID , error ) {
209209 return sourceSubnetID , nil
210210 },
211- GetValidatorSetF : func (context.Context , uint64 , ids.ID ) (map [ids. NodeID ] * validators.GetValidatorOutput , error ) {
212- return getValidatorsOutput , nil
211+ GetWarpValidatorSetF : func (context.Context , uint64 , ids.ID ) (validators.WarpSet , error ) {
212+ return validators . FlattenValidatorSet ( validatorSet )
213213 },
214214 }
215- snowCtx .ValidatorState = state
216215 return snowCtx
217216}
218217
@@ -247,20 +246,29 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner
247246 unsignedMsg , err := avalancheWarp .NewUnsignedMessage (constants .UnitTestID , cChainID , addressedCall .Bytes ())
248247 require .NoError (err )
249248
250- getValidatorsOutput := make (map [ids.NodeID ]* validators.GetValidatorOutput )
251- blsSignatures := make ([]* bls.Signature , 0 , numKeys )
249+ var (
250+ warpValidators = validators.WarpSet {
251+ Validators : make ([]* validators.Warp , 0 , numKeys ),
252+ TotalWeight : 20 * uint64 (numKeys ),
253+ }
254+ blsSignatures = make ([]* bls.Signature , 0 , numKeys )
255+ )
252256 for i := 0 ; i < numKeys ; i ++ {
253- sig , err := testVdrs [i ].sk .Sign (unsignedMsg .Bytes ())
257+ vdr := testVdrs [i ]
258+ sig , err := vdr .sk .Sign (unsignedMsg .Bytes ())
254259 require .NoError (err )
255-
256- validatorOutput := & validators.GetValidatorOutput {
257- NodeID : testVdrs [i ].nodeID ,
258- Weight : 20 ,
259- PublicKey : testVdrs [i ].vdr .PublicKey ,
260- }
261- getValidatorsOutput [testVdrs [i ].nodeID ] = validatorOutput
262260 blsSignatures = append (blsSignatures , sig )
261+
262+ pk := vdr .sk .PublicKey ()
263+ warpValidators .Validators = append (warpValidators .Validators , & validators.Warp {
264+ PublicKey : pk ,
265+ PublicKeyBytes : bls .PublicKeyToUncompressedBytes (pk ),
266+ Weight : 20 ,
267+ NodeIDs : []ids.NodeID {vdr .nodeID },
268+ })
263269 }
270+ agoUtils .Sort (warpValidators .Validators )
271+
264272 aggregateSignature , err := bls .AggregateSignatures (blsSignatures )
265273 require .NoError (err )
266274 bitSet := set .NewBits ()
@@ -285,13 +293,13 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner
285293 require .Equal (chainID , cChainID )
286294 return constants .PrimaryNetworkID , nil // Return Primary Network SubnetID
287295 },
288- GetValidatorSetF : func (_ context.Context , _ uint64 , subnetID ids.ID ) (map [ids. NodeID ] * validators.GetValidatorOutput , error ) {
296+ GetWarpValidatorSetF : func (_ context.Context , _ uint64 , subnetID ids.ID ) (validators.WarpSet , error ) {
289297 expectedSubnetID := snowCtx .SubnetID
290298 if requirePrimaryNetworkSigners {
291299 expectedSubnetID = constants .PrimaryNetworkID
292300 }
293301 require .Equal (expectedSubnetID , subnetID )
294- return getValidatorsOutput , nil
302+ return warpValidators , nil
295303 },
296304 }
297305
@@ -718,26 +726,27 @@ func makeWarpPredicateTests(tb testing.TB) map[string]precompiletest.PredicateTe
718726 testName := fmt .Sprintf ("%d validators w/ %d signers/repeated PublicKeys" , totalNodes , numSigners )
719727
720728 pred := createPredicate (numSigners )
721- getValidatorsOutput := make (map [ids.NodeID ]* validators.GetValidatorOutput , totalNodes )
729+ validatorSet := make (map [ids.NodeID ]* validators.GetValidatorOutput , totalNodes )
722730 for i := 0 ; i < totalNodes ; i ++ {
723- getValidatorsOutput [testVdrs [i ].nodeID ] = & validators.GetValidatorOutput {
731+ validatorSet [testVdrs [i ].nodeID ] = & validators.GetValidatorOutput {
724732 NodeID : testVdrs [i ].nodeID ,
725733 Weight : 20 ,
726734 PublicKey : testVdrs [i % numSigners ].vdr .PublicKey ,
727735 }
728736 }
737+ warpValidators , err := validators .FlattenValidatorSet (validatorSet )
738+ require .NoError (tb , err )
729739
730740 snowCtx := utilstest .NewTestSnowContext (tb )
731741
732- state : = & validatorstest.State {
742+ snowCtx . ValidatorState = & validatorstest.State {
733743 GetSubnetIDF : func (context.Context , ids.ID ) (ids.ID , error ) {
734744 return sourceSubnetID , nil
735745 },
736- GetValidatorSetF : func (context.Context , uint64 , ids.ID ) (map [ids. NodeID ] * validators.GetValidatorOutput , error ) {
737- return getValidatorsOutput , nil
746+ GetWarpValidatorSetF : func (context.Context , uint64 , ids.ID ) (validators.WarpSet , error ) {
747+ return warpValidators , nil
738748 },
739749 }
740- snowCtx .ValidatorState = state
741750
742751 predicateTests [testName ] = createValidPredicateTest (snowCtx , uint64 (numSigners ), pred )
743752 }
0 commit comments