aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/vm_test.go
diff options
context:
space:
mode:
authoraaronbuchwald <[email protected]>2020-12-15 10:45:45 -0500
committerGitHub <[email protected]>2020-12-15 10:45:45 -0500
commit2d0a37c6490dc9a4ec36ee4ebbed01c790f0426a (patch)
tree7e3feca0be37f81b9ca5d2780f351b3051be32c8 /plugin/evm/vm_test.go
parent95cc7cb766d5bb23a771da35b3774159b2e1e1d1 (diff)
parent1b6ea47fbf59f5e4569e88433f3ab85a45a1df75 (diff)
Merge pull request #73 from ava-labs/shutdown
Simplify shutdown
Diffstat (limited to 'plugin/evm/vm_test.go')
-rw-r--r--plugin/evm/vm_test.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go
index 4593404..dbceb1b 100644
--- a/plugin/evm/vm_test.go
+++ b/plugin/evm/vm_test.go
@@ -8,6 +8,7 @@ import (
"encoding/json"
"math/big"
"testing"
+ "time"
"github.com/ava-labs/avalanchego/api/keystore"
"github.com/ava-labs/avalanchego/cache"
@@ -155,11 +156,23 @@ func GenesisVM(t *testing.T, finishBootstrapping bool) (chan engCommon.Message,
func TestVMGenesis(t *testing.T) {
_, vm, _, _ := GenesisVM(t, true)
- defer func() {
- if err := vm.Shutdown(); err != nil {
- t.Fatal(err)
+ shutdownChan := make(chan error, 1)
+ shutdownFunc := func() {
+ err := vm.Shutdown()
+ shutdownChan <- err
+ }
+
+ go shutdownFunc()
+ shutdownTimeout := 10 * time.Millisecond
+ ticker := time.NewTicker(shutdownTimeout)
+ select {
+ case <-ticker.C:
+ t.Fatalf("VM shutdown took longer than timeout: %v", shutdownTimeout)
+ case err := <-shutdownChan:
+ if err != nil {
+ t.Fatalf("Shutdown errored: %s", err)
}
- }()
+ }
}
func TestIssueAtomicTxs(t *testing.T) {