Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orderwatch: Add missing test coverage #416

Merged
merged 26 commits into from Sep 17, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5a1001f
Add integration tests for OrderWatcher and fix issue where we weren't…
fabioberger Sep 14, 2019
ff0e236
Add CHANGELOG entry for bug fix
fabioberger Sep 14, 2019
8381083
Fix linter errors
fabioberger Sep 14, 2019
5a027e2
Fix misnamed variable
fabioberger Sep 14, 2019
8a5b5d7
Fix test name
fabioberger Sep 14, 2019
d70f0c5
Omit OrderWatcher tests from WASM build
fabioberger Sep 15, 2019
6f1b67f
Run tests sequentially since we now have multiple test suites making …
fabioberger Sep 15, 2019
99df2d5
Use the same ethClient across tests to make debugging Ganache easier …
fabioberger Sep 15, 2019
1bdd3b1
Remove unnecessary snapshotting
fabioberger Sep 15, 2019
f69eb51
Remove duplicate test
fabioberger Sep 15, 2019
ed93a5f
Add bug fix to unreleased 4.1.0 changelog entry
fabioberger Sep 17, 2019
c8a6d42
Fix rebase issues
fabioberger Sep 17, 2019
b71fa9e
Use init instead of TestSetup pattern so that all tests can be run in…
fabioberger Sep 17, 2019
8a66f72
Standardize on importing the Ethereum rpc package as `ethrpc`
fabioberger Sep 17, 2019
e4583f3
set content length to a variable to improve readability
fabioberger Sep 17, 2019
ec040ed
Add timeout when listening for OrderEvent to provide developers with …
fabioberger Sep 17, 2019
8db0e7b
Use assert instead of require in places where the tests could continu…
fabioberger Sep 17, 2019
6ed7d4d
Move contract wrapper declarations into the init function so we don't…
fabioberger Sep 17, 2019
b1530de
Pass in a context with a timeout to calls to WaitMined so that they a…
fabioberger Sep 17, 2019
d18bff8
Split tests so that only those that tests that can be run in parallel do
fabioberger Sep 17, 2019
58d74c4
Pass context into goroutines and cancel them when tests exit
fabioberger Sep 17, 2019
6de0fd8
Call cancelFn after WaitMined completes to cancel the context before …
fabioberger Sep 17, 2019
a4e57cd
Add missing serial flag on additional tests
fabioberger Sep 17, 2019
64dd326
Add waitForOrderEvents helper method
fabioberger Sep 17, 2019
7b9ab60
Use require for orders length assertion
fabioberger Sep 17, 2019
e1673d4
Add waitTxnSuccessfullyMined convenience method
fabioberger Sep 17, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Use init instead of TestSetup pattern so that all tests can be run in…

…dependently
  • Loading branch information
fabioberger committed Sep 17, 2019
commit b71fa9e0260c0f87d0ea95fb8557daed721640a6
@@ -70,12 +70,16 @@ func init() {

var ethRPCClient *ethRpc.Client

func TestSetup(t *testing.T) {
func init() {
var err error
ethRPCClient, err = ethRpc.Dial(constants.GanacheEndpoint)
require.NoError(t, err)
if err != nil {
panic(err)
}
blockchainLifecycle, err = ethereum.NewBlockchainLifecycle(ethRPCClient)
require.NoError(t, err)
if err != nil {
panic(err)
}
}

func TestBrowserIntegration(t *testing.T) {
@@ -66,12 +66,16 @@ type testCase struct {
var rpcClient *ethRpc.Client
var blockchainLifecycle *ethereum.BlockchainLifecycle

func TestSetup(t *testing.T) {
func init() {
var err error
rpcClient, err = ethRpc.Dial(constants.GanacheEndpoint)
require.NoError(t, err)
if err != nil {
panic(err)
}
blockchainLifecycle, err = ethereum.NewBlockchainLifecycle(rpcClient)
require.NoError(t, err)
if err != nil {
panic(err)
}
}

func TestBatchValidateOffChainCases(t *testing.T) {
@@ -38,12 +38,16 @@ var zrxAmount = new(big.Int).Mul(big.NewInt(100), eighteenDecimalsInBaseUnits)
var tokenID = big.NewInt(1)
var rpcClient *ethrpc.Client

func TestSetup(t *testing.T) {
func init() {
This conversation was marked as resolved by fabioberger

This comment has been minimized.

Copy link
@albrow

albrow Sep 17, 2019

Member

Just a thought: I'm pretty comfortable with this init function so far because it purely does set up and should never fail under normal circumstances. However, we should keep an eye on it. We want to avoid testing conditions/assumptions/behaviors within init because the error messages can be harder to interpret. Anything that could reasonably fail should be included in a test function where we have access to testing.T.

var err error
rpcClient, err = ethrpc.Dial(constants.GanacheEndpoint)
require.NoError(t, err)
if err != nil {
panic(err)
}
blockchainLifecycle, err = ethereum.NewBlockchainLifecycle(rpcClient)
require.NoError(t, err)
if err != nil {
panic(err)
}
}

func TestOrderWatcherUnfundedInsufficientERC20Balance(t *testing.T) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.