Skip to content

Commit

Permalink
Add waitForCompletion param to testbed_invoke
Browse files Browse the repository at this point in the history
SIMDomain and Noto are fully wired up to support completing transactions, but
Zeto and Pente will require more work.

Signed-off-by: Andrew Richardson <[email protected]>
  • Loading branch information
awrichar committed Sep 20, 2024
1 parent ab45951 commit 67f4e96
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
11 changes: 7 additions & 4 deletions core/go/pkg/testbed/testbed_jsonrpc_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ func (tb *testbed) prepareTransaction(ctx context.Context, invocation tktypes.Pr
}

func (tb *testbed) rpcTestbedInvoke() rpcserver.RPCHandler {
return rpcserver.RPCMethod1(func(ctx context.Context,
return rpcserver.RPCMethod2(func(ctx context.Context,
invocation tktypes.PrivateContractInvoke,
waitForCompletion bool,
) (bool, error) {

tx, err := tb.prepareTransaction(ctx, invocation)
Expand All @@ -278,9 +279,11 @@ func (tb *testbed) rpcTestbedInvoke() rpcserver.RPCHandler {
}

// Wait for the domain to index the transaction events
err = tb.c.DomainManager().WaitForTransaction(ctx, tx.ID)
if err != nil {
return false, err
if waitForCompletion {
err = tb.c.DomainManager().WaitForTransaction(ctx, tx.ID)
if err != nil {
return false, err
}
}
return true, nil
})
Expand Down
4 changes: 2 additions & 2 deletions core/go/pkg/testbed/ut_simdomain_notarized_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func TestDemoNotarizedCoinSelection(t *testing.T) {
"to": "wallets.org1.aaaaaa",
"amount": "123000000000000000000"
}`),
})
}, true)
assert.Nil(t, rpcErr)

rpcErr = tbRPC.CallRPC(ctx, tktypes.RawJSON{}, "testbed_invoke", &tktypes.PrivateContractInvoke{
Expand All @@ -637,7 +637,7 @@ func TestDemoNotarizedCoinSelection(t *testing.T) {
"to": "wallets.org2.bbbbbb",
"amount": "23000000000000000000"
}`),
})
}, true)
assert.Nil(t, rpcErr)

// Check we can also use the utility function externally to resolve verifiers
Expand Down
20 changes: 10 additions & 10 deletions domains/noto/internal/noto/e2e_noto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestNoto(t *testing.T) {
To: notaryName,
Amount: ethtypes.NewHexInteger64(100),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand All @@ -195,7 +195,7 @@ func TestNoto(t *testing.T) {
To: recipient1Name,
Amount: ethtypes.NewHexInteger64(100),
}),
})
}, true)
require.NotNil(t, rpcerr)
assert.ErrorContains(t, rpcerr.Error(), "PD200009")
assert.True(t, boolResult)
Expand All @@ -213,7 +213,7 @@ func TestNoto(t *testing.T) {
To: recipient1Name,
Amount: ethtypes.NewHexInteger64(150),
}),
})
}, true)
require.NotNil(t, rpcerr)
assert.ErrorContains(t, rpcerr.Error(), "PD200005")

Expand All @@ -230,7 +230,7 @@ func TestNoto(t *testing.T) {
To: recipient1Name,
Amount: ethtypes.NewHexInteger64(50),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand All @@ -253,7 +253,7 @@ func TestNoto(t *testing.T) {
To: recipient2Name,
Amount: ethtypes.NewHexInteger64(50),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func TestNotoApprove(t *testing.T) {
To: notaryName,
Amount: ethtypes.NewHexInteger64(100),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestNotoApprove(t *testing.T) {
Delegate: *ethtypes.MustNewAddress(recipient1Key),
Call: prepared.EncodedCall,
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down Expand Up @@ -420,7 +420,7 @@ func TestNotoSelfSubmit(t *testing.T) {
To: notaryName,
Amount: ethtypes.NewHexInteger64(100),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand All @@ -441,7 +441,7 @@ func TestNotoSelfSubmit(t *testing.T) {
To: recipient1Name,
Amount: ethtypes.NewHexInteger64(50),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand All @@ -464,7 +464,7 @@ func TestNotoSelfSubmit(t *testing.T) {
To: recipient2Name,
Amount: ethtypes.NewHexInteger64(50),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void testSimpleStorage() throws Exception {
JsonHex.addressFrom(contractAddr),
simpleStorageDeployABI,
deployValues
));
), false);
assertFalse(contractAddr.isBlank());

// TODO: This is a hack because we need to define a way for domain transactions to
Expand All @@ -148,7 +148,7 @@ void testSimpleStorage() throws Exception {
JsonHex.addressFrom(contractAddr),
simpleStorageSetABI,
setValues
));
), false);
assertFalse(contractAddr.isBlank());

}
Expand Down
4 changes: 2 additions & 2 deletions domains/test/pvp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func notoMint(ctx context.Context, t *testing.T, rpc rpcbackend.Backend, notoAdd
To: to,
Amount: ethtypes.NewHexInteger64(amount),
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func notoApprove(ctx context.Context, t *testing.T, rpc rpcbackend.Backend, noto
Delegate: delegate,
Call: call,
}),
})
}, true)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down
8 changes: 4 additions & 4 deletions domains/zeto/integration-test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (s *zetoDomainTestSuite) testZetoFungible(t *testing.T, tokenName string) {
To: controllerName,
Amount: ethtypes.NewHexInteger64(10),
}),
})
}, false)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand All @@ -220,7 +220,7 @@ func (s *zetoDomainTestSuite) testZetoFungible(t *testing.T, tokenName string) {
To: controllerName,
Amount: ethtypes.NewHexInteger64(20),
}),
})
}, false)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand All @@ -243,7 +243,7 @@ func (s *zetoDomainTestSuite) testZetoFungible(t *testing.T, tokenName string) {
To: recipient1Name,
Amount: ethtypes.NewHexInteger64(10),
}),
})
}, false)
require.NotNil(t, rpcerr)
assert.Regexp(t, "failed to send base ledger transaction: PD011516: Reverted: 0x118cdaa.*", rpcerr.Error())
assert.True(t, boolResult)
Expand All @@ -257,7 +257,7 @@ func (s *zetoDomainTestSuite) testZetoFungible(t *testing.T, tokenName string) {
To: recipient1Name,
Amount: ethtypes.NewHexInteger64(25),
}),
})
}, false)
if rpcerr != nil {
require.NoError(t, rpcerr.Error())
}
Expand Down

0 comments on commit 67f4e96

Please sign in to comment.