Skip to content

Commit

Permalink
Update harness test
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp committed Dec 7, 2021
1 parent 0e5bfbd commit 870408f
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions client/asset/eth/nodeclient_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,16 @@ func testRedeem(t *testing.T) {
}

tests := []struct {
name string
sleep time.Duration
redeemerClient *nodeClient
redeemer *accounts.Account
swaps []*asset.Contract
redemptions []*asset.Redemption
isRedeemable []bool
finalStates []dexeth.SwapStep
addAmt bool
name string
sleep time.Duration
redeemerClient *nodeClient
redeemer *accounts.Account
swaps []*asset.Contract
redemptions []*asset.Redemption
isRedeemable []bool
finalStates []dexeth.SwapStep
addAmt bool
expectRedeemErr bool
}{
{
name: "ok before locktime",
Expand Down Expand Up @@ -814,10 +815,11 @@ func testRedeem(t *testing.T) {
addAmt: false,
},
{
name: "duplicate secret hashes",
sleep: time.Second * 8,
redeemerClient: participantEthClient,
redeemer: participantAcct,
name: "duplicate secret hashes",
expectRedeemErr: true,
sleep: time.Second * 8,
redeemerClient: participantEthClient,
redeemer: participantAcct,
swaps: []*asset.Contract{
newContract(lockTime, secretHashes[7], 1),
newContract(lockTime, secretHashes[8], 1),
Expand Down Expand Up @@ -885,6 +887,12 @@ func testRedeem(t *testing.T) {
}

tx, err := test.redeemerClient.redeem(ctx, test.redemptions, maxFeeRate, 0)
if test.expectRedeemErr {
if err == nil {
t.Fatalf("%s: expected error but did not get", test.name)
}
continue
}
if err != nil {
t.Fatalf("%s: redeem error: %v", test.name, err)
}
Expand All @@ -895,7 +903,7 @@ func testRedeem(t *testing.T) {
t.Fatalf("%s: redeemer pending in balance error: %v", test.name, err)
}

if test.addAmt && dexeth.WeiToGwei(bal.PendingIn) != uint64(numSwaps) {
if test.addAmt && dexeth.WeiToGwei(bal.PendingIn) != uint64(len(test.swaps)) {
t.Fatalf("%s: unexpected pending in balance %s", test.name, bal.PendingIn)
}

Expand Down

0 comments on commit 870408f

Please sign in to comment.