github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/txs/subnet_validator_test.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package txs 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 11 "github.com/MetalBlockchain/metalgo/ids" 12 "github.com/MetalBlockchain/metalgo/utils/constants" 13 ) 14 15 func TestSubnetValidatorVerifySubnetID(t *testing.T) { 16 require := require.New(t) 17 18 // Error path 19 { 20 vdr := &SubnetValidator{ 21 Subnet: constants.PrimaryNetworkID, 22 } 23 24 err := vdr.Verify() 25 require.ErrorIs(err, errBadSubnetID) 26 } 27 28 // Happy path 29 { 30 vdr := &SubnetValidator{ 31 Subnet: ids.GenerateTestID(), 32 Validator: Validator{ 33 Wght: 1, 34 }, 35 } 36 37 require.NoError(vdr.Verify()) 38 } 39 }