Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Cleaned up the orderwatcher tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Jul 22, 2020
1 parent 0c9f436 commit 1a3f412
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion zeroex/orderwatch/order_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ func (w *Watcher) handleBlockEvents(ctx context.Context, events []*blockwatch.Ev
// of the oldest block in the blockwatcher, we must revalidate the
// order because we may be missing relevant block events.
if firstBlockInDB.Number.Cmp(previousValidationBlockNumber) == 1 {
logger.Info("Hit Breakpoint")
orderHashToDBOrder[recentlyValidatedOrder.Hash] = recentlyValidatedOrder
orderHashToEvents[recentlyValidatedOrder.Hash] = []*zeroex.ContractEvent{}
}
Expand Down
8 changes: 4 additions & 4 deletions zeroex/orderwatch/order_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package orderwatch
import (
"context"
"flag"
"fmt"
"math/big"
"testing"
"time"
Expand Down Expand Up @@ -1640,7 +1639,7 @@ func TestMissingOrderEvents(t *testing.T) {
validator, err := ordervalidator.New(
&SlowContractCaller{
caller: ethRPCClient,
contractCallDelay: 5 * time.Second,
contractCallDelay: 1 * time.Second,
},
constants.TestChainID,
ethereumRPCMaxContentLength,
Expand Down Expand Up @@ -1726,6 +1725,7 @@ func TestMissingOrderEvents(t *testing.T) {
assert.Equal(t, zeroex.ESOrderUnexpired, orderEvents[1].EndState)
}

// TODO(jalextowle): De-duplicate the code in this test and the above test
func TestMissingOrderEventsWithMissingBlocks(t *testing.T) {
if !serialTestsEnabled {
t.Skip("Serial tests (tests which cannot run in parallel) are disabled. You can enable them with the --serial flag")
Expand All @@ -1743,7 +1743,7 @@ func TestMissingOrderEventsWithMissingBlocks(t *testing.T) {
validator, err := ordervalidator.New(
&SlowContractCaller{
caller: ethRPCClient,
contractCallDelay: 5 * time.Second,
contractCallDelay: 1 * time.Second,
},
constants.TestChainID,
ethereumRPCMaxContentLength,
Expand All @@ -1770,6 +1770,7 @@ func TestMissingOrderEventsWithMissingBlocks(t *testing.T) {
require.NoError(t, err)
waitTxnSuccessfullyMined(t, ethClient, txn)

// TODO(jalextowle): Is there a better way to do this that takes less time?
// Create enough new orders for the block containing the cancellation to
// be missing from the database.
for i := 0; i < dbOpts.MaxMiniHeaders; i++ {
Expand Down Expand Up @@ -1836,7 +1837,6 @@ func TestMissingOrderEventsWithMissingBlocks(t *testing.T) {
orderWatcher.blockEventsChan <- newBlockEvents

// Await canceled event
fmt.Println("1")
orderEvents := waitForOrderEvents(t, orderEventsChan, 2, 10*time.Second)
assert.Equal(t, zeroex.ESOrderCancelled, orderEvents[0].EndState)
// TODO(jalextowle): This event probably shouldn't be fired
Expand Down

0 comments on commit 1a3f412

Please sign in to comment.