aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/chequebook/cheque_test.go
diff options
context:
space:
mode:
authorBenoit Verkindt <benoit.verkindt@gmail.com>2017-09-08 05:14:47 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-09-08 05:14:47 +0800
commite3db1236de65619d26e87eb7c886e565fcc2eafc (patch)
tree91c3155e3a988ca3ffa084acbb34b0cc94031603 /contracts/chequebook/cheque_test.go
parent02b4d074f688293a3443d5ca73c357c1ded22ddb (diff)
downloadgo-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.tar
go-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.tar.gz
go-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.tar.bz2
go-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.tar.lz
go-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.tar.xz
go-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.tar.zst
go-tangerine-e3db1236de65619d26e87eb7c886e565fcc2eafc.zip
contracts/chequebook: fix race in test (#15058)
Diffstat (limited to 'contracts/chequebook/cheque_test.go')
-rw-r--r--contracts/chequebook/cheque_test.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/contracts/chequebook/cheque_test.go b/contracts/chequebook/cheque_test.go
index 5f6a54a1c..b7555d081 100644
--- a/contracts/chequebook/cheque_test.go
+++ b/contracts/chequebook/cheque_test.go
@@ -232,8 +232,8 @@ func TestDeposit(t *testing.T) {
balance := new(big.Int).SetUint64(42)
chbook.Deposit(balance)
backend.Commit()
- if chbook.balance.Cmp(balance) != 0 {
- t.Fatalf("expected balance %v, got %v", balance, chbook.balance)
+ if chbook.Balance().Cmp(balance) != 0 {
+ t.Fatalf("expected balance %v, got %v", balance, chbook.Balance())
}
amount := common.Big1
@@ -243,8 +243,8 @@ func TestDeposit(t *testing.T) {
}
backend.Commit()
exp := new(big.Int).SetUint64(41)
- if chbook.balance.Cmp(exp) != 0 {
- t.Fatalf("expected balance %v, got %v", exp, chbook.balance)
+ if chbook.Balance().Cmp(exp) != 0 {
+ t.Fatalf("expected balance %v, got %v", exp, chbook.Balance())
}
// autodeposit on each issue
@@ -259,8 +259,8 @@ func TestDeposit(t *testing.T) {
t.Fatalf("expected no error, got %v", err)
}
backend.Commit()
- if chbook.balance.Cmp(balance) != 0 {
- t.Fatalf("expected balance %v, got %v", balance, chbook.balance)
+ if chbook.Balance().Cmp(balance) != 0 {
+ t.Fatalf("expected balance %v, got %v", balance, chbook.Balance())
}
// autodeposit off
@@ -277,11 +277,11 @@ func TestDeposit(t *testing.T) {
backend.Commit()
exp = new(big.Int).SetUint64(40)
- if chbook.balance.Cmp(exp) != 0 {
- t.Fatalf("expected balance %v, got %v", exp, chbook.balance)
+ if chbook.Balance().Cmp(exp) != 0 {
+ t.Fatalf("expected balance %v, got %v", exp, chbook.Balance())
}
- // autodeposit every 10ms if new cheque issued
+ // autodeposit every 30ms if new cheque issued
interval := 30 * time.Millisecond
chbook.AutoDeposit(interval, common.Big1, balance)
_, err = chbook.Issue(addr1, amount)
@@ -296,14 +296,14 @@ func TestDeposit(t *testing.T) {
backend.Commit()
exp = new(big.Int).SetUint64(38)
- if chbook.balance.Cmp(exp) != 0 {
- t.Fatalf("expected balance %v, got %v", exp, chbook.balance)
+ if chbook.Balance().Cmp(exp) != 0 {
+ t.Fatalf("expected balance %v, got %v", exp, chbook.Balance())
}
time.Sleep(3 * interval)
backend.Commit()
- if chbook.balance.Cmp(balance) != 0 {
- t.Fatalf("expected balance %v, got %v", balance, chbook.balance)
+ if chbook.Balance().Cmp(balance) != 0 {
+ t.Fatalf("expected balance %v, got %v", balance, chbook.Balance())
}
exp = new(big.Int).SetUint64(40)
@@ -319,8 +319,8 @@ func TestDeposit(t *testing.T) {
}
time.Sleep(3 * interval)
backend.Commit()
- if chbook.balance.Cmp(exp) != 0 {
- t.Fatalf("expected balance %v, got %v", exp, chbook.balance)
+ if chbook.Balance().Cmp(exp) != 0 {
+ t.Fatalf("expected balance %v, got %v", exp, chbook.Balance())
}
_, err = chbook.Issue(addr1, amount)
@@ -330,8 +330,8 @@ func TestDeposit(t *testing.T) {
time.Sleep(1 * interval)
backend.Commit()
- if chbook.balance.Cmp(balance) != 0 {
- t.Fatalf("expected balance %v, got %v", balance, chbook.balance)
+ if chbook.Balance().Cmp(balance) != 0 {
+ t.Fatalf("expected balance %v, got %v", balance, chbook.Balance())
}
chbook.AutoDeposit(1*interval, common.Big0, balance)
@@ -352,8 +352,8 @@ func TestDeposit(t *testing.T) {
backend.Commit()
exp = new(big.Int).SetUint64(39)
- if chbook.balance.Cmp(exp) != 0 {
- t.Fatalf("expected balance %v, got %v", exp, chbook.balance)
+ if chbook.Balance().Cmp(exp) != 0 {
+ t.Fatalf("expected balance %v, got %v", exp, chbook.Balance())
}
}