Skip to content
76 changes: 51 additions & 25 deletions graft/coreth/tests/warp/warp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,56 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
})

var _ = ginkgo.Describe("[Warp]", func() {
testFunc := func(sendingSubnet *Subnet, receivingSubnet *Subnet) {
tc := e2e.NewTestContext()
w := newWarpTest(tc.DefaultContext(), sendingSubnet, receivingSubnet)

ginkgo.GinkgoLogr.Info("Sending message from A to B")
w.sendMessageFromSendingSubnet()

ginkgo.GinkgoLogr.Info("Aggregating signatures via API")
w.aggregateSignaturesViaAPI()

ginkgo.GinkgoLogr.Info("Delivering addressed call payload to receiving subnet")
w.deliverAddressedCallToReceivingSubnet()
type testCombination struct {
name string
sendingSubnet func() *Subnet
receivingSubnet func() *Subnet
}

ginkgo.GinkgoLogr.Info("Delivering block hash payload to receiving subnet")
w.deliverBlockHashPayload()
testCombinations := []testCombination{
// TODO: Uncomment these tests when we have a way to run them in CI, currently we should not depend on Subnet-EVM
// as Coreth and Subnet-EVM have different release cycles. The problem is that once we update AvalancheGo (protocol version),
// we need to update Subnet-EVM to the same protocol version. Until then all Subnet-EVM tests are broken, so it's blocking Coreth development.
// It's best to not run these tests until we have a way to run them in CI.
// {"SubnetA -> C-Chain", func() *Subnet { return subnetA }, func() *Subnet { return cChainSubnetDetails }},
// {"C-Chain -> SubnetA", func() *Subnet { return cChainSubnetDetails }, func() *Subnet { return subnetA }},
{"C-Chain -> C-Chain", func() *Subnet { return cChainSubnetDetails }, func() *Subnet { return cChainSubnetDetails }},
}

ginkgo.GinkgoLogr.Info("Executing warp load test")
w.warpLoad()
for _, combination := range testCombinations {
ginkgo.Describe(combination.name, ginkgo.Ordered, func() {
var w *warpTest

ginkgo.BeforeAll(func() {
w = newWarpTest(combination.sendingSubnet(), combination.receivingSubnet())
})

ginkgo.It("should send warp message from sending subnet", func() {
ginkgo.GinkgoLogr.Info("Sending message from sending subnet")
w.sendMessageFromSendingSubnet()
})

ginkgo.It("should aggregate signatures via API", func() {
ginkgo.GinkgoLogr.Info("Aggregating signatures via API")
w.aggregateSignaturesViaAPI()
})

ginkgo.It("should deliver addressed call payload to receiving subnet", func() {
ginkgo.GinkgoLogr.Info("Delivering addressed call payload to receiving subnet")
w.deliverAddressedCallToReceivingSubnet()
})

ginkgo.It("should deliver block hash payload", func() {
ginkgo.GinkgoLogr.Info("Delivering block hash payload to receiving subnet")
w.deliverBlockHashPayload()
})

ginkgo.It("should handle warp load testing", func() {
ginkgo.GinkgoLogr.Info("Executing warp load test")
w.warpLoad()
})
})
}
// TODO: Uncomment these tests when we have a way to run them in CI, currently we should not depend on Subnet-EVM
// as Coreth and Subnet-EVM have different release cycles. The problem is that once we update AvalancheGo (protocol version),
// we need to update Subnet-EVM to the same protocol version. Until then all Subnet-EVM tests are broken, so it's blocking Coreth development.
// It's best to not run these tests until we have a way to run them in CI.
// ginkgo.It("SubnetA -> C-Chain", func() { testFunc(subnetA, cChainSubnetDetails) })
// ginkgo.It("C-Chain -> SubnetA", func() { testFunc(cChainSubnetDetails, subnetA) })
ginkgo.It("C-Chain -> C-Chain", func() { testFunc(cChainSubnetDetails, cChainSubnetDetails) })
})

type warpTest struct {
Expand Down Expand Up @@ -178,8 +202,10 @@ type warpTest struct {
addressedCallSignedMessage *avalancheWarp.Message
}

func newWarpTest(ctx context.Context, sendingSubnet *Subnet, receivingSubnet *Subnet) *warpTest {
func newWarpTest(sendingSubnet *Subnet, receivingSubnet *Subnet) *warpTest {
require := require.New(ginkgo.GinkgoT())
tc := e2e.NewTestContext()
ctx := tc.DefaultContext()

sendingSubnetFundedKey := sendingSubnet.PreFundedKey
receivingSubnetFundedKey := receivingSubnet.PreFundedKey
Expand Down Expand Up @@ -240,9 +266,9 @@ func (w *warpTest) initClients() {
}

func (w *warpTest) sendMessageFromSendingSubnet() {
require := require.New(ginkgo.GinkgoT())
tc := e2e.NewTestContext()
ctx := tc.DefaultContext()
require := require.New(ginkgo.GinkgoT())

client := w.sendingSubnetClients[0]

Expand Down
81 changes: 55 additions & 26 deletions graft/subnet-evm/tests/warp/warp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,59 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
})

var _ = ginkgo.Describe("[Warp]", func() {
testFunc := func(sendingSubnet *Subnet, receivingSubnet *Subnet) {
tc := e2e.NewTestContext()
w := newWarpTest(tc.DefaultContext(), sendingSubnet, receivingSubnet)

log.Info("Sending message from A to B")
w.sendMessageFromSendingSubnet()

log.Info("Aggregating signatures via API")
w.aggregateSignaturesViaAPI()

log.Info("Delivering addressed call payload to receiving subnet")
w.deliverAddressedCallToReceivingSubnet()

log.Info("Delivering block hash payload to receiving subnet")
w.deliverBlockHashPayload()
type testCombination struct {
name string
sendingSubnet func() *Subnet
receivingSubnet func() *Subnet
}

log.Info("bindings test: verifying warp message and blockchain ID")
w.warpBindingsTest()
testCombinations := []testCombination{
{"SubnetA -> SubnetB", func() *Subnet { return subnetA }, func() *Subnet { return subnetB }},
{"SubnetA -> SubnetA", func() *Subnet { return subnetA }, func() *Subnet { return subnetA }},
{"SubnetA -> C-Chain", func() *Subnet { return subnetA }, func() *Subnet { return cChainSubnetDetails }},
{"C-Chain -> SubnetA", func() *Subnet { return cChainSubnetDetails }, func() *Subnet { return subnetA }},
{"C-Chain -> C-Chain", func() *Subnet { return cChainSubnetDetails }, func() *Subnet { return cChainSubnetDetails }},
}

log.Info("Executing warp load test")
w.warpLoad()
for _, combination := range testCombinations {
ginkgo.Describe(combination.name, ginkgo.Ordered, func() {
var w *warpTest

ginkgo.BeforeAll(func() {
w = newWarpTest(combination.sendingSubnet(), combination.receivingSubnet())
})

ginkgo.It("should send warp message from sending subnet", func() {
log.Info("Sending message from sending subnet")
w.sendMessageFromSendingSubnet()
})

ginkgo.It("should aggregate signatures via API", func() {
log.Info("Aggregating signatures via API")
w.aggregateSignaturesViaAPI()
})

ginkgo.It("should deliver addressed call payload to receiving subnet", func() {
log.Info("Delivering addressed call payload to receiving subnet")
w.deliverAddressedCallToReceivingSubnet()
})

ginkgo.It("should deliver block hash payload", func() {
log.Info("Delivering block hash payload to receiving subnet")
w.deliverBlockHashPayload()
})

ginkgo.It("should verify warp bindings", func() {
log.Info("bindings test: verifying warp message and blockchain ID")
w.warpBindingsTest()
})

ginkgo.It("should handle warp load testing", func() {
log.Info("Executing warp load test")
w.warpLoad()
})
})
}
ginkgo.It("SubnetA -> SubnetB", func() { testFunc(subnetA, subnetB) })
ginkgo.It("SubnetA -> SubnetA", func() { testFunc(subnetA, subnetA) })
ginkgo.It("SubnetA -> C-Chain", func() { testFunc(subnetA, cChainSubnetDetails) })
ginkgo.It("C-Chain -> SubnetA", func() { testFunc(cChainSubnetDetails, subnetA) })
ginkgo.It("C-Chain -> C-Chain", func() { testFunc(cChainSubnetDetails, cChainSubnetDetails) })
})

type warpTest struct {
Expand Down Expand Up @@ -212,8 +238,10 @@ type warpTest struct {
addressedCallSignedMessage *avalancheWarp.Message
}

func newWarpTest(ctx context.Context, sendingSubnet *Subnet, receivingSubnet *Subnet) *warpTest {
func newWarpTest(sendingSubnet *Subnet, receivingSubnet *Subnet) *warpTest {
require := require.New(ginkgo.GinkgoT())
tc := e2e.NewTestContext()
ctx := tc.DefaultContext()

sendingSubnetFundedKey := sendingSubnet.PreFundedKey
receivingSubnetFundedKey := receivingSubnet.PreFundedKey
Expand Down Expand Up @@ -288,9 +316,10 @@ func (*warpTest) getBlockHashAndNumberFromTxReceipt(ctx context.Context, client
}

func (w *warpTest) sendMessageFromSendingSubnet() {
require := require.New(ginkgo.GinkgoT())
tc := e2e.NewTestContext()
ctx := tc.DefaultContext()
require := require.New(ginkgo.GinkgoT())

client := w.sendingSubnetClients[0]

blockHash, blockNumber := w.sendWarpMessageTx(ctx, client)
Expand Down