contracts: fix megacheck errors (#14916)
* contracts: fix megacheck errors * contracts: drop useless sleep, lets see what breaks
This commit is contained in:
parent
fff6e03a79
commit
26b2d6e1aa
@ -376,12 +376,12 @@ func (self *Chequebook) autoDeposit(interval time.Duration) {
|
|||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
self.quit = make(chan bool)
|
self.quit = make(chan bool)
|
||||||
quit := self.quit
|
quit := self.quit
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
FOR:
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-quit:
|
case <-quit:
|
||||||
break FOR
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
self.lock.Lock()
|
self.lock.Lock()
|
||||||
if self.balance.Cmp(self.buffer) < 0 {
|
if self.balance.Cmp(self.buffer) < 0 {
|
||||||
@ -395,7 +395,6 @@ func (self *Chequebook) autoDeposit(interval time.Duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outbox can issue cheques from a single contract to a single beneficiary.
|
// Outbox can issue cheques from a single contract to a single beneficiary.
|
||||||
@ -436,7 +435,6 @@ type Inbox struct {
|
|||||||
sender common.Address // local peer's address to send cashing tx from
|
sender common.Address // local peer's address to send cashing tx from
|
||||||
signer *ecdsa.PublicKey // peer's public key
|
signer *ecdsa.PublicKey // peer's public key
|
||||||
txhash string // tx hash of last cashing tx
|
txhash string // tx hash of last cashing tx
|
||||||
abigen bind.ContractBackend // blockchain API
|
|
||||||
session *contract.ChequebookSession // abi contract backend with tx opts
|
session *contract.ChequebookSession // abi contract backend with tx opts
|
||||||
quit chan bool // when closed causes autocash to stop
|
quit chan bool // when closed causes autocash to stop
|
||||||
maxUncashed *big.Int // threshold that triggers autocashing
|
maxUncashed *big.Int // threshold that triggers autocashing
|
||||||
@ -525,12 +523,12 @@ func (self *Inbox) autoCash(cashInterval time.Duration) {
|
|||||||
ticker := time.NewTicker(cashInterval)
|
ticker := time.NewTicker(cashInterval)
|
||||||
self.quit = make(chan bool)
|
self.quit = make(chan bool)
|
||||||
quit := self.quit
|
quit := self.quit
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
FOR:
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-quit:
|
case <-quit:
|
||||||
break FOR
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
self.lock.Lock()
|
self.lock.Lock()
|
||||||
if self.cheque != nil && self.cheque.Amount.Cmp(self.cashed) != 0 {
|
if self.cheque != nil && self.cheque.Amount.Cmp(self.cashed) != 0 {
|
||||||
@ -543,7 +541,6 @@ func (self *Inbox) autoCash(cashInterval time.Duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive is called to deposit the latest cheque to the incoming Inbox.
|
// Receive is called to deposit the latest cheque to the incoming Inbox.
|
||||||
|
@ -170,7 +170,6 @@ func TestVerifyErrors(t *testing.T) {
|
|||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(5)
|
|
||||||
chbox, err := NewInbox(key1, contr0, addr1, &key0.PublicKey, backend)
|
chbox, err := NewInbox(key1, contr0, addr1, &key0.PublicKey, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
@ -193,7 +192,7 @@ func TestVerifyErrors(t *testing.T) {
|
|||||||
received, err = chbox.Receive(ch1)
|
received, err = chbox.Receive(ch1)
|
||||||
t.Logf("correct error: %v", err)
|
t.Logf("correct error: %v", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected receiver error, got none")
|
t.Fatalf("expected receiver error, got none and value %v", received)
|
||||||
}
|
}
|
||||||
|
|
||||||
ch2, err := chbook1.Issue(addr1, amount)
|
ch2, err := chbook1.Issue(addr1, amount)
|
||||||
@ -203,7 +202,7 @@ func TestVerifyErrors(t *testing.T) {
|
|||||||
received, err = chbox.Receive(ch2)
|
received, err = chbox.Receive(ch2)
|
||||||
t.Logf("correct error: %v", err)
|
t.Logf("correct error: %v", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected sender error, got none")
|
t.Fatalf("expected sender error, got none and value %v", received)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = chbook1.Issue(addr1, new(big.Int).SetInt64(-1))
|
_, err = chbook1.Issue(addr1, new(big.Int).SetInt64(-1))
|
||||||
@ -215,7 +214,7 @@ func TestVerifyErrors(t *testing.T) {
|
|||||||
received, err = chbox.Receive(ch0)
|
received, err = chbox.Receive(ch0)
|
||||||
t.Logf("correct error: %v", err)
|
t.Logf("correct error: %v", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected incorrect amount error, got none")
|
t.Fatalf("expected incorrect amount error, got none and value %v", received)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user