Skip to content

Commit

Permalink
Merge branch 'dev' into options-before-verify
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Dec 28, 2023
2 parents e1b3547 + 0c7ff5a commit 67610a7
Show file tree
Hide file tree
Showing 18 changed files with 868 additions and 1,080 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
target-branch: "dev"
8 changes: 1 addition & 7 deletions api/admin/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ import (
type loadVMsTest struct {
admin *Admin
ctrl *gomock.Controller
mockLog *logging.MockLogger
mockVMManager *vms.MockManager
mockVMRegistry *registry.MockVMRegistry
}

func initLoadVMsTest(t *testing.T) *loadVMsTest {
ctrl := gomock.NewController(t)

mockLog := logging.NewMockLogger(ctrl)
mockVMRegistry := registry.NewMockVMRegistry(ctrl)
mockVMManager := vms.NewMockManager(ctrl)

return &loadVMsTest{
admin: &Admin{Config: Config{
Log: mockLog,
Log: logging.NoLog{},
VMRegistry: mockVMRegistry,
VMManager: mockVMManager,
}},
ctrl: ctrl,
mockLog: mockLog,
mockVMManager: mockVMManager,
mockVMRegistry: mockVMRegistry,
}
Expand Down Expand Up @@ -67,7 +64,6 @@ func TestLoadVMsSuccess(t *testing.T) {
id2: alias2[1:],
}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil)
Expand All @@ -84,7 +80,6 @@ func TestLoadVMsReloadFails(t *testing.T) {

resources := initLoadVMsTest(t)

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
// Reload fails
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(nil, nil, errTest)

Expand All @@ -108,7 +103,6 @@ func TestLoadVMsGetAliasesFails(t *testing.T) {
// every vm is at least aliased to itself.
alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest)
Expand Down
19 changes: 6 additions & 13 deletions api/info/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,20 @@ var errTest = errors.New("non-nil error")
type getVMsTest struct {
info *Info
ctrl *gomock.Controller
mockLog *logging.MockLogger
mockVMManager *vms.MockManager
}

func initGetVMsTest(t *testing.T) *getVMsTest {
ctrl := gomock.NewController(t)

service := Info{}
mockLog := logging.NewMockLogger(ctrl)
mockVMManager := vms.NewMockManager(ctrl)

service.log = mockLog
service.VMManager = mockVMManager

return &getVMsTest{
info: &service,
info: &Info{
Parameters: Parameters{
VMManager: mockVMManager,
},
log: logging.NoLog{},
},
ctrl: ctrl,
mockLog: mockLog,
mockVMManager: mockVMManager,
}
}
Expand All @@ -62,7 +58,6 @@ func TestGetVMsSuccess(t *testing.T) {
id2: alias2[1:],
}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(vmIDs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil)
Expand All @@ -76,7 +71,6 @@ func TestGetVMsSuccess(t *testing.T) {
func TestGetVMsVMsListFactoriesFails(t *testing.T) {
resources := initGetVMsTest(t)

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(nil, errTest)

reply := GetVMsReply{}
Expand All @@ -93,7 +87,6 @@ func TestGetVMsGetAliasesFails(t *testing.T) {
vmIDs := []ids.ID{id1, id2}
alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(vmIDs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest)
Expand Down
1 change: 0 additions & 1 deletion scripts/mocks.mockgen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ github.com/ava-labs/avalanchego/snow/validators=SubnetConnector=snow/validators/
github.com/ava-labs/avalanchego/utils/crypto/keychain=Ledger=utils/crypto/keychain/mock_ledger.go
github.com/ava-labs/avalanchego/utils/filesystem=Reader=utils/filesystem/mock_io.go
github.com/ava-labs/avalanchego/utils/hashing=Hasher=utils/hashing/mock_hasher.go
github.com/ava-labs/avalanchego/utils/logging=Logger=utils/logging/mock_logger.go
github.com/ava-labs/avalanchego/utils/resource=User=utils/resource/mock_user.go
github.com/ava-labs/avalanchego/vms/avm/block=Block=vms/avm/block/mock_block.go
github.com/ava-labs/avalanchego/vms/avm/metrics=Metrics=vms/avm/metrics/mock_metrics.go
Expand Down
246 changes: 0 additions & 246 deletions utils/logging/mock_logger.go

This file was deleted.

4 changes: 4 additions & 0 deletions vms/avm/block/executor/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ func (b *Block) Reject(context.Context) error {
}
}

// If we added transactions to the mempool, we should be willing to build a
// block.
b.manager.mempool.RequestBuildBlock()

b.rejected = true
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions vms/avm/block/executor/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ func TestBlockReject(t *testing.T) {

mempool := mempool.NewMockMempool(ctrl)
mempool.EXPECT().Add(validTx).Return(nil) // Only add the one that passes verification
mempool.EXPECT().RequestBuildBlock()

preferredID := ids.GenerateTestID()
mockPreferredState := state.NewMockDiff(ctrl)
Expand Down Expand Up @@ -916,6 +917,7 @@ func TestBlockReject(t *testing.T) {
mempool := mempool.NewMockMempool(ctrl)
mempool.EXPECT().Add(tx1).Return(nil)
mempool.EXPECT().Add(tx2).Return(nil)
mempool.EXPECT().RequestBuildBlock()

preferredID := ids.GenerateTestID()
mockPreferredState := state.NewMockDiff(ctrl)
Expand Down
Loading

0 comments on commit 67610a7

Please sign in to comment.