*: upgrade tests to use T.Cleanup()

This commit is contained in:
Anna Shaleva 2021-03-01 14:14:15 +03:00
parent 0cec99a3ea
commit 2c81fc8b8e
41 changed files with 137 additions and 220 deletions

View file

@ -59,6 +59,7 @@ func newTestChainWithCustomCfg(t *testing.T, f func(*config.Config)) *Blockchain
func newTestChainWithCustomCfgAndStore(t *testing.T, st storage.Store, f func(*config.Config)) *Blockchain {
chain := initTestChain(t, st, f)
go chain.Run()
t.Cleanup(chain.Close)
return chain
}
@ -174,7 +175,6 @@ func TestBug1728(t *testing.T) {
require.NoError(t, err)
bc := newTestChain(t)
defer bc.Close()
aer, err := invokeContractMethod(bc, 10000000000,
bc.contracts.Management.Hash, "deploy", rawNef, rawManifest)
@ -242,13 +242,14 @@ func TestCreateBasicChain(t *testing.T) {
const prefix = "../rpc/server/testdata/"
bc := newTestChain(t)
defer bc.Close()
initBasicChain(t, bc)
if saveChain {
outStream, err := os.Create(prefix + "testblocks.acc")
require.NoError(t, err)
defer outStream.Close()
t.Cleanup(func() {
outStream.Close()
})
writer := io.NewBinWriterFromIO(outStream)
writer.WriteU32LE(bc.BlockHeight())