core,network: shutdown services in tests properly

This commit is contained in:
Evgenii Stratonikov 2020-04-22 17:43:50 +03:00
parent 295f9e3ee1
commit c508a36827
2 changed files with 11 additions and 1 deletions

View file

@ -203,6 +203,7 @@ func TestCreateBasicChain(t *testing.T) {
var neoAmount = util.Fixed8FromInt64(99999000)
var neoRemainder = util.Fixed8FromInt64(100000000) - neoAmount
bc := newTestChain(t)
defer bc.Close()
// Move almost all NEO to one simple account.
txMoveNeo := transaction.NewContractTX()

View file

@ -59,7 +59,16 @@ func TestServerNotSendsVerack(t *testing.T) {
p2 = newLocalPeer(t, s)
)
s.id = 1
go s.run()
finished := make(chan struct{})
go func() {
s.run()
close(finished)
}()
defer func() {
// close via quit as server was started via `run()`, not `Start()`
close(s.quit)
<-finished
}()
na, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:3000")
p.netaddr = *na