Skip to content

Commit

Permalink
XRPL keyring signer (#15)
Browse files Browse the repository at this point in the history
Integrate cosmos keyring for the XRPL txs signing.
  • Loading branch information
dzmitryhil authored Sep 27, 2023
1 parent 1190d01 commit 5db2455
Show file tree
Hide file tree
Showing 15 changed files with 425 additions and 1,191 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/relayer-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
ci_step: [
"lint",
"test",
"integration tests",
]
include:
Expand All @@ -24,6 +25,12 @@ jobs:
wasm-cache: true
linter-cache: true
docker-cache: false
- ci_step: "lint"
command: "make test-relayer"
go-cache: true
wasm-cache: true
linter-cache: false
docker-cache: false
- ci_step: "integration tests"
command: "make rebuild-dev-env && make restart-dev-env && make test-integration"
go-cache: true
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ go-lint:
test-integration:
cd integration-tests && go test -v --tags=integrationtests -mod=readonly -parallel=4 ./...

.PHONY: test-relayer
test-relayer:
cd relayer && go test -v -mod=readonly -parallel=4 ./...

.PHONY: restart-dev-env
restart-dev-env:
crust znet remove && crust znet start --profiles=integration-tests-modules,xrpl --timeout-commit 0.5s
Expand Down
226 changes: 108 additions & 118 deletions integration-tests/client/xrpl_rpc_test.go

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions integration-tests/client/xrpl_scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ func TestFullHistoryScanAccountTx(t *testing.T) {

const txsCount = 20

senderWallet := chains.XRPL.GenWallet(ctx, t, 100)
t.Logf("Sender account: %s", senderWallet.Account)
senderAcc := chains.XRPL.GenAccount(ctx, t, 100)
t.Logf("Sender account: %s", senderAcc)

recipientWallet := chains.XRPL.GenWallet(ctx, t, 0)
t.Logf("Recipient account: %s", recipientWallet.Account)
recipientAcc := chains.XRPL.GenAccount(ctx, t, 0)
t.Logf("Recipient account: %s", recipientAcc)

// generate txs
writtenTxHashes := sendMultipleTxs(ctx, t, txsCount, senderWallet, recipientWallet, chains.XRPL)
writtenTxHashes := sendMultipleTxs(ctx, t, txsCount, senderAcc, recipientAcc, chains.XRPL)

rpcClientConfig := xrpl.DefaultRPCClientConfig(chains.XRPL.Config().RPCAddress)
// update the page limit to low to emulate multiple pages
Expand All @@ -40,9 +40,10 @@ func TestFullHistoryScanAccountTx(t *testing.T) {
chains.Log,
http.NewRetryableClient(http.DefaultClientConfig()),
)

// enable just historical scan
scannerCfg := xrpl.AccountScannerConfig{
Account: senderWallet.Account,
Account: senderAcc,
RecentScanEnabled: false,
FullScanEnabled: true,
RetryDelay: time.Second,
Expand All @@ -63,11 +64,11 @@ func TestRecentHistoryScanAccountTx(t *testing.T) {

const txsCount = 20

senderWallet := chains.XRPL.GenWallet(ctx, t, 100)
t.Logf("Sender account: %s", senderWallet.Account)
senderAcc := chains.XRPL.GenAccount(ctx, t, 100)
t.Logf("Sender account: %s", senderAcc)

recipientWallet := chains.XRPL.GenWallet(ctx, t, 0)
t.Logf("Recipient account: %s", recipientWallet.Account)
recipientAcc := chains.XRPL.GenAccount(ctx, t, 0)
t.Logf("Recipient account: %s", recipientAcc)

rpcClientConfig := xrpl.DefaultRPCClientConfig(chains.XRPL.Config().RPCAddress)
// update the page limit to low to emulate multiple pages
Expand All @@ -80,7 +81,7 @@ func TestRecentHistoryScanAccountTx(t *testing.T) {

// update config to use recent scan only
scannerCfg := xrpl.AccountScannerConfig{
Account: senderWallet.Account,
Account: senderAcc,
RecentScanEnabled: true,
RecentScanWindow: 5,
RepeatRecentScan: true,
Expand All @@ -100,7 +101,7 @@ func TestRecentHistoryScanAccountTx(t *testing.T) {
writeDone := make(chan struct{})
go func() {
defer close(writeDone)
writtenTxHashes = sendMultipleTxs(ctx, t, 20, senderWallet, recipientWallet, chains.XRPL)
writtenTxHashes = sendMultipleTxs(ctx, t, 20, senderAcc, recipientAcc, chains.XRPL)
}()

txsCh := make(chan rippledata.Transaction, txsCount)
Expand All @@ -122,21 +123,21 @@ func sendMultipleTxs(
ctx context.Context,
t *testing.T,
count int,
senderWallet, recipientWallet integrationtests.XRPLWallet,
senderAcc, recipientAcc rippledata.Account,
xrplChain integrationtests.XRPLChain,
) map[string]struct{} {
writtenTxHashes := make(map[string]struct{})
for i := 0; i < count; i++ {
xrpAmount, err := rippledata.NewAmount("100000") // 0.1 XRP tokens
require.NoError(t, err)
xrpPaymentTx := rippledata.Payment{
Destination: recipientWallet.Account,
Destination: recipientAcc,
Amount: *xrpAmount,
TxBase: rippledata.TxBase{
TransactionType: rippledata.PAYMENT,
},
}
require.NoError(t, xrplChain.AutoFillSignAndSubmitTx(ctx, t, &xrpPaymentTx, senderWallet))
require.NoError(t, xrplChain.AutoFillSignAndSubmitTx(ctx, t, &xrpPaymentTx, senderAcc))
writtenTxHashes[xrpPaymentTx.Hash.String()] = struct{}{}
}
t.Logf("Successfully sent %d transactions", len(writtenTxHashes))
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ replace (
require (
cosmossdk.io/math v1.1.2
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230920110418-b30366f1b19b
github.com/CoreumFoundation/coreum/v3 v3.0.0-20230926091045-52c8d17ce588
github.com/CoreumFoundation/coreum/v3 v3.0.0-20230921140203-3e716cbeec41
github.com/CoreumFoundation/coreumbridge-xrpl/relayer v1.0.0
github.com/rubblelabs/ripple v0.0.0-20230908201244-7f73b1fe5e22
github.com/samber/lo v1.38.1
Expand Down Expand Up @@ -67,7 +67,7 @@ require (
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect
github.com/cosmos/cosmos-sdk v0.47.5 // indirect
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230920110418-b30366f1b19b h1:nSNvOe9oRVl0Ijph3u/e1nZi7j4vGhYyTI3NVbPLdXI=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20230920110418-b30366f1b19b/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/coreum/v3 v3.0.0-20230926091045-52c8d17ce588 h1:Dpe3iz1fEtxRYqosJa+BodEsMCRm1dQQgTiW4AaUAhQ=
github.com/CoreumFoundation/coreum/v3 v3.0.0-20230926091045-52c8d17ce588/go.mod h1:JD6ogmhLUI+v9QJfuLT/Qyyrfugo7Cg76Pys/KehbwY=
github.com/CoreumFoundation/coreum/v3 v3.0.0-20230921140203-3e716cbeec41 h1:VOZfhW5mCDdBgt/X+3QMAQfuvUOEhPvYJZ7Ve5FS0Gw=
github.com/CoreumFoundation/coreum/v3 v3.0.0-20230921140203-3e716cbeec41/go.mod h1:JD6ogmhLUI+v9QJfuLT/Qyyrfugo7Cg76Pys/KehbwY=
github.com/CosmWasm/wasmd v0.41.0 h1:fmwxSbwb50zZDcBaayYFRLIaSFca+EFld1WOaQi49jg=
github.com/CosmWasm/wasmd v0.41.0/go.mod h1:0Sds1q2IsPaTN1gHa3BNOYcUFgtGvxH7CXEXPgoihns=
github.com/CosmWasm/wasmvm v1.3.0 h1:x12X4bKlUPS7TT9QQP45+fJo2sp30GEbiSSgb9jsec8=
Expand Down
Loading

0 comments on commit 5db2455

Please sign in to comment.