From ddac46efe5f0de1501f48b33bd1a073786ccf89f Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Fri, 19 Aug 2022 19:36:51 +0200 Subject: [PATCH 1/2] fix: tests --- benthos/committed_transactions_test.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/benthos/committed_transactions_test.yaml b/benthos/committed_transactions_test.yaml index 5b0603a..1824e14 100644 --- a/benthos/committed_transactions_test.yaml +++ b/benthos/committed_transactions_test.yaml @@ -41,7 +41,7 @@ tests: - json_equals: [ { "index": { - "_id": "TRANSACTION-foo-test-22", + "_id": "TRANSACTION-test-22", "_index": "ledger" } }, @@ -83,7 +83,7 @@ tests: }, { "index": { - "_id": "ASSET-foo-test-bank-USD", + "_id": "ASSET-test-bank-USD", "_index": "ledger" } }, @@ -104,7 +104,7 @@ tests: }, { "index": { - "_id": "ASSET-foo-test-world-USD", + "_id": "ASSET-test-world-USD", "_index": "ledger" } }, @@ -125,7 +125,7 @@ tests: }, { "update": { - "_id": "ACCOUNT-foo-test-bank", + "_id": "ACCOUNT-test-bank", "_index": "ledger" } }, @@ -164,7 +164,7 @@ tests: }, { "update": { - "_id": "ACCOUNT-foo-test-world", + "_id": "ACCOUNT-test-world", "_index": "ledger" } }, From c4cdf99e2a4659c108c5a96250043ad739566a11 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Fri, 19 Aug 2022 19:45:03 +0200 Subject: [PATCH 2/2] feat: Add 'ledger' property inside indexed documents data. This allow the frontend to make cross ledger requests and know on which ledger transactions are. --- benthos/committed_transactions.blobl | 6 +++--- benthos/committed_transactions_test.yaml | 11 ++++++++--- benthos/saved_metadata.blobl | 3 ++- benthos/saved_metadata_test.yaml | 5 +++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/benthos/committed_transactions.blobl b/benthos/committed_transactions.blobl index 5355192..857ce51 100644 --- a/benthos/committed_transactions.blobl +++ b/benthos/committed_transactions.blobl @@ -79,7 +79,7 @@ map committedTransactions { "_index": env("OPENSEARCH_INDEX"), "_id": "TRANSACTION-%s-%s".format(this.ledger, t.data.txid) } - }, t.merge({ + }, t.assign({"data": {"ledger": this.ledger}}).merge({ "when": this.date, "ledger": this.ledger })]). @@ -91,7 +91,7 @@ map committedTransactions { "_index": env("OPENSEARCH_INDEX"), "_id": "ASSET-%s-%s-%s".format(this.ledger, t.data.account, t.data.name) } - }, t.merge({ + }, t.assign({"data": {"ledger": this.ledger}}).merge({ "when": this.date, "ledger": this.ledger })]). @@ -109,7 +109,7 @@ map committedTransactions { "_index": env("OPENSEARCH_INDEX"), "_id": "ACCOUNT-%s-%s".format(this.ledger, t.upsert.data.address) } - }, t]). + }, t.assign({"upsert": {"data": {"ledger": this.ledger}}})]). flatten(), ].flatten() } diff --git a/benthos/committed_transactions_test.yaml b/benthos/committed_transactions_test.yaml index 1824e14..7120b19 100644 --- a/benthos/committed_transactions_test.yaml +++ b/benthos/committed_transactions_test.yaml @@ -58,7 +58,8 @@ tests: ], "reference": "", "timestamp": "2022-03-16T13:11:38Z", - "txid": 22 + "txid": 22, + "ledger": "test" }, "indexed": { "amount": [ @@ -93,6 +94,7 @@ tests: "input": 1000, "name": "USD", "output": 0, + "ledger": "test" }, "indexed": { "name": "USD", @@ -114,6 +116,7 @@ tests: "input": 0, "name": "USD", "output": 1000, + "ledger": "test" }, "indexed": { "name": "USD", @@ -152,7 +155,8 @@ tests: "input": 1000, "output": 0 } - } + }, + "ledger": "test" }, "indexed": { "address": "bank" @@ -191,7 +195,8 @@ tests: "input": 0, "output": 1000 } - } + }, + "ledger": "test" }, "indexed": { "address": "world" diff --git a/benthos/saved_metadata.blobl b/benthos/saved_metadata.blobl index b8e1aa2..5e62a3a 100644 --- a/benthos/saved_metadata.blobl +++ b/benthos/saved_metadata.blobl @@ -21,7 +21,8 @@ map savedMetadata { "address": this.payload.targetId, "volumes": {}, "balances": {}, - "metadata": this.payload.metadata + "metadata": this.payload.metadata, + "ledger": this.ledger }, "indexed": { "address": this.payload.targetId diff --git a/benthos/saved_metadata_test.yaml b/benthos/saved_metadata_test.yaml index 525a447..4ace944 100644 --- a/benthos/saved_metadata_test.yaml +++ b/benthos/saved_metadata_test.yaml @@ -22,7 +22,7 @@ tests: - - json_equals: [{ "update": { - "_id": "TRANSACTION-foo-test-22", + "_id": "TRANSACTION-test-22", "_index": "ledger" } }, @@ -39,7 +39,8 @@ tests: "foo": "bar", "test": "\"quoted-field\"" }, - "volumes": { } + "volumes": { }, + "ledger": "test" }, "indexed": { "address": "22"