Skip to content

Commit

Permalink
Remove mock for Versions interface (#3312)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Aug 20, 2024
1 parent acfcfe4 commit 76f1918
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 57 deletions.
2 changes: 1 addition & 1 deletion scripts/mocks.mockgen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ github.com/ava-labs/avalanchego/vms/avm/txs/mempool=Mempool=vms/avm/txs/mempool/
github.com/ava-labs/avalanchego/vms/components/avax=TransferableIn=vms/components/avax/mock_transferable_in.go
github.com/ava-labs/avalanchego/vms/components/verify=Verifiable=vms/components/verify/mock_verifiable.go
github.com/ava-labs/avalanchego/vms/platformvm/block=Block=vms/platformvm/block/mock_block.go
github.com/ava-labs/avalanchego/vms/platformvm/state=Chain,Diff,State,Versions=vms/platformvm/state/mock_state.go
github.com/ava-labs/avalanchego/vms/platformvm/state=Chain,Diff,State=vms/platformvm/state/mock_state.go
github.com/ava-labs/avalanchego/vms/platformvm/state=StakerIterator=vms/platformvm/state/mock_staker_iterator.go
github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool=Mempool=vms/platformvm/txs/mempool/mock_mempool.go
github.com/ava-labs/avalanchego/vms/platformvm/utxo=Verifier=vms/platformvm/utxo/mock_verifier.go
Expand Down
25 changes: 9 additions & 16 deletions vms/platformvm/state/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
)

func TestDiffMissingState(t *testing.T) {
ctrl := gomock.NewController(t)
type nilStateGetter struct{}

versions := NewMockVersions(ctrl)
func (nilStateGetter) GetState(ids.ID) (Chain, bool) {
return nil, false
}

func TestDiffMissingState(t *testing.T) {
parentID := ids.GenerateTestID()
versions.EXPECT().GetState(parentID).Times(1).Return(nil, false)

_, err := NewDiff(parentID, versions)
_, err := NewDiff(parentID, nilStateGetter{})
require.ErrorIs(t, err, ErrMissingParentState)
}

Expand Down Expand Up @@ -587,16 +587,9 @@ func TestDiffSubnetOwner(t *testing.T) {
}

func TestDiffSubnetManager(t *testing.T) {
require := require.New(t)
ctrl := gomock.NewController(t)

state := newTestState(t, memdb.New())

states := NewMockVersions(ctrl)
lastAcceptedID := ids.GenerateTestID()
states.EXPECT().GetState(lastAcceptedID).Return(state, true).AnyTimes()

var (
require = require.New(t)
state = newTestState(t, memdb.New())
newManager = chainIDAndAddr{ids.GenerateTestID(), []byte{1, 2, 3, 4}}
subnetID = ids.GenerateTestID()
)
Expand All @@ -606,7 +599,7 @@ func TestDiffSubnetManager(t *testing.T) {
require.Equal(ids.Empty, chainID)
require.Nil(addr)

d, err := NewDiff(lastAcceptedID, states)
d, err := NewDiffOn(state)
require.NoError(err)

chainID, addr, err = d.GetSubnetManager(subnetID)
Expand Down
42 changes: 2 additions & 40 deletions vms/platformvm/state/mock_state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76f1918

Please sign in to comment.