Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Nov 18, 2022
1 parent 8e7d7c3 commit 2d45cec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion chain/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package chain

import (
"context"
"errors"
"testing"
"time"
Expand Down Expand Up @@ -150,7 +151,7 @@ func TestBlock(t *testing.T) {
}
for i, tv := range tt {
blk := tv.createBlk()
err := blk.Verify()
err := blk.Verify(context.Background())
if !errors.Is(err, tv.expectedVerifyErr) {
t.Fatalf("#%d: block verify expected error %v, got %v", i, tv.expectedVerifyErr, err)
}
Expand Down
40 changes: 23 additions & 17 deletions tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ var _ = ginkgo.BeforeSuite(func() {
// TODO: test appsender
v := &vm.VM{AirdropData: airdropData}
err := v.Initialize(
context.Background(),
ctx,
db,
genesisBytes,
Expand All @@ -172,7 +173,7 @@ var _ = ginkgo.BeforeSuite(func() {
})

var hd map[string]*common.HTTPHandler
hd, err = v.CreateHandlers()
hd, err = v.CreateHandlers(context.Background())
gomega.Ω(err).Should(gomega.BeNil())

httpServer := httptest.NewServer(hd[vm.PublicEndpoint].Handler)
Expand Down Expand Up @@ -207,7 +208,7 @@ var _ = ginkgo.BeforeSuite(func() {
var _ = ginkgo.AfterSuite(func() {
for _, iv := range instances {
iv.httpServer.Close()
err := iv.vm.Shutdown()
err := iv.vm.Shutdown(context.Background())
gomega.Ω(err).Should(gomega.BeNil())
}
})
Expand Down Expand Up @@ -297,19 +298,21 @@ var _ = ginkgo.Describe("Tx Types", func() {
})

ginkgo.By("build block in the node 1", func() {
blk, err := instances[1].vm.BuildBlock()
ctx := context.Background()

blk, err := instances[1].vm.BuildBlock(ctx)
gomega.Ω(err).To(gomega.BeNil())

gomega.Ω(blk.Verify()).To(gomega.BeNil())
gomega.Ω(blk.Verify(ctx)).To(gomega.BeNil())
gomega.Ω(blk.Status()).To(gomega.Equal(choices.Processing))

err = instances[1].vm.SetPreference(blk.ID())
err = instances[1].vm.SetPreference(ctx, blk.ID())
gomega.Ω(err).To(gomega.BeNil())

gomega.Ω(blk.Accept()).To(gomega.BeNil())
gomega.Ω(blk.Accept(ctx)).To(gomega.BeNil())
gomega.Ω(blk.Status()).To(gomega.Equal(choices.Accepted))

lastAccepted, err := instances[1].vm.LastAccepted()
lastAccepted, err := instances[1].vm.LastAccepted(ctx)
gomega.Ω(err).To(gomega.BeNil())
gomega.Ω(lastAccepted).To(gomega.Equal(blk.ID()))
})
Expand Down Expand Up @@ -710,6 +713,7 @@ func createIssueTx(i instance, input *chain.Input, signer *ecdsa.PrivateKey) {
}

func asyncBlockPush(i instance, c chan struct{}) {
ctx := context.Background()
timer := time.NewTicker(500 * time.Millisecond)
for {
select {
Expand All @@ -721,21 +725,21 @@ func asyncBlockPush(i instance, c chan struct{}) {
// manually ack ready sig as in engine
<-i.toEngine

blk, err := i.vm.BuildBlock()
blk, err := i.vm.BuildBlock(ctx)
if err != nil {
continue
}

gomega.Ω(blk.Verify()).To(gomega.BeNil())
gomega.Ω(blk.Verify(ctx)).To(gomega.BeNil())
gomega.Ω(blk.Status()).To(gomega.Equal(choices.Processing))

err = i.vm.SetPreference(blk.ID())
err = i.vm.SetPreference(ctx, blk.ID())
gomega.Ω(err).To(gomega.BeNil())

gomega.Ω(blk.Accept()).To(gomega.BeNil())
gomega.Ω(blk.Accept(ctx)).To(gomega.BeNil())
gomega.Ω(blk.Status()).To(gomega.Equal(choices.Accepted))

lastAccepted, err := i.vm.LastAccepted()
lastAccepted, err := i.vm.LastAccepted(ctx)
gomega.Ω(err).To(gomega.BeNil())
gomega.Ω(lastAccepted).To(gomega.Equal(blk.ID()))
}
Expand All @@ -748,19 +752,21 @@ func expectBlkAccept(i instance) {
// manually ack ready sig as in engine
<-i.toEngine

blk, err := i.vm.BuildBlock()
ctx := context.Background()

blk, err := i.vm.BuildBlock(ctx)
gomega.Ω(err).To(gomega.BeNil())

gomega.Ω(blk.Verify()).To(gomega.BeNil())
gomega.Ω(blk.Verify(ctx)).To(gomega.BeNil())
gomega.Ω(blk.Status()).To(gomega.Equal(choices.Processing))

err = i.vm.SetPreference(blk.ID())
err = i.vm.SetPreference(ctx, blk.ID())
gomega.Ω(err).To(gomega.BeNil())

gomega.Ω(blk.Accept()).To(gomega.BeNil())
gomega.Ω(blk.Accept(ctx)).To(gomega.BeNil())
gomega.Ω(blk.Status()).To(gomega.Equal(choices.Accepted))

lastAccepted, err := i.vm.LastAccepted()
lastAccepted, err := i.vm.LastAccepted(ctx)
gomega.Ω(err).To(gomega.BeNil())
gomega.Ω(lastAccepted).To(gomega.Equal(blk.ID()))
}
Expand Down

0 comments on commit 2d45cec

Please sign in to comment.