Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iroha): adding checkEmpty param to request #1484

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"test:tap:all": "tap",
"test:all": "yarn test:jest:all && yarn test:tap:all",
"posttest:all": "tap --no-check-coverage --coverage-report=lcov && codecov",
"postinstall": "patch-package",
"test:unit": "tap --ts --node-arg=--max-old-space-size=4096 --timeout=600 --no-check-coverage \"packages/cactus-*/src/test/typescript/unit/\"",
"test:benchmark": "tap --ts --jobs=1 --no-timeout --no-check-coverage \"packages/cactus-*/src/test/typescript/benchmark/\"",
"test:browser": "karma start karma.conf.js",
Expand Down Expand Up @@ -123,6 +124,8 @@
"node-polyfill-webpack-plugin": "1.1.4",
"npm-run-all": "4.1.5",
"npm-watch": "0.11.0",
"patch-package": "6.4.7",
"postinstall-postinstall": "2.1.0",
"prettier": "2.1.2",
"protoc-gen-ts": "0.6.0",
"run-time-error": "1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cactus-plugin-ledger-connector-iroha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"@types/google-protobuf": "3.15.5",
"axios": "0.21.4",
"express": "4.17.1",
"grpc": "1.24.11",
"iroha-helpers-ts": "0.9.25-ss",
"grpc": "1.24.3",
"iroha-helpers": "0.9.3",
"openapi-types": "7.0.1",
"prom-client": "13.1.0",
"typescript-optional": "2.0.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Server } from "http";
import * as grpc from "grpc";
import { Server as SecureServer } from "https";
import { CommandService_v1Client as CommandService } from "iroha-helpers-ts/lib/proto/endpoint_grpc_pb";
import { QueryService_v1Client as QueryService } from "iroha-helpers-ts/lib/proto/endpoint_grpc_pb";
import commands from "iroha-helpers-ts/lib/commands/index";
import queries from "iroha-helpers-ts/lib/queries";
import { CommandService_v1Client as CommandService } from "iroha-helpers/lib/proto/endpoint_grpc_pb";
import { QueryService_v1Client as QueryService } from "iroha-helpers/lib/proto/endpoint_grpc_pb";
import commands from "iroha-helpers/lib/commands";
import queries from "iroha-helpers/lib/queries";
import type { Express } from "express";
import {
GrantablePermission,
GrantablePermissionMap,
} from "iroha-helpers-ts/lib/proto/primitive_pb";
} from "iroha-helpers/lib/proto/primitive_pb";

import OAS from "../json/openapi.json";

Expand Down Expand Up @@ -264,7 +264,8 @@ export class PluginLedgerConnectorIroha
accountId: req.params[0],
key: req.params[1],
value: req.params[2],
oldValue: req.params[3],
oldValue: req.params[3] ? undefined : req.params[3],
checkEmpty: req.params[4],
},
);
return { transactionReceipt: response };
Expand Down Expand Up @@ -518,6 +519,10 @@ export class PluginLedgerConnectorIroha
const response = await queries.getPendingTransactions(queryOptions, {
pageSize: req.params[0],
firstTxHash: req.params[1],
ordering: {
field: undefined,
direction: undefined,
},
});
return { transactionReceipt: response };
} catch (err) {
Expand All @@ -530,6 +535,10 @@ export class PluginLedgerConnectorIroha
accountId: req.params[0],
pageSize: req.params[1],
firstTxHash: req.params[2],
ordering: {
field: undefined,
direction: undefined,
},
});
return { transactionReceipt: response };
} catch (err) {
Expand All @@ -545,6 +554,10 @@ export class PluginLedgerConnectorIroha
assetId: req.params[1],
pageSize: req.params[2],
firstTxHash: req.params[3],
ordering: {
field: undefined,
direction: undefined,
},
},
);
return { transactionReceipt: response };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
IrohaQuery,
KeyPair,
} from "../../../main/typescript/generated/openapi/typescript-axios";
import cryptoHelper from "iroha-helpers-ts/lib/cryptoHelper";
import cryptoHelper from "iroha-helpers/lib/cryptoHelper";

const testCase = "runs tx on an Iroha v1.2.0 ledger";
const logLevel: LogLevelDesc = "ERROR";
Expand All @@ -49,7 +49,7 @@ test("BEFORE " + testCase, async (t: Test) => {
});

// Flaky test, does not always work, fix it once we have time
test.skip(testCase, async (t: Test) => {
test(testCase, async (t: Test) => {
const postgres1 = new PostgresTestContainer({ logLevel });
const postgres2 = new PostgresTestContainer({ logLevel });
test.onFinish(async () => {
Expand Down Expand Up @@ -95,6 +95,12 @@ test.skip(testCase, async (t: Test) => {
await iroha1.stop();
await iroha2.stop();
});

test.onFailure(async () => {
await iroha1.stop();
await iroha2.stop();
});

await iroha1.start();
await iroha2.start();
const irohaHost1 = await internalIpV4();
Expand Down Expand Up @@ -188,7 +194,7 @@ test.skip(testCase, async (t: Test) => {
t.ok(res);
t.ok(res.data);
t.equal(res.status, 200);
t.equal(res.data.transactionReceipt.status, "COMMITTED");
t.equal(res.data.transactionReceipt.status[0], "COMMITTED");
}

//Verify the generated priv/pub keys are equivalent to those pulled from the ledger.
Expand Down Expand Up @@ -221,7 +227,7 @@ test.skip(testCase, async (t: Test) => {
t.ok(res);
t.ok(res.data);
t.equal(res.status, 200);
t.equal(res.data.transactionReceipt.status, "COMMITTED");
t.equal(res.data.transactionReceipt.status[0], "COMMITTED");
}
//Iroha1's admin is initialized with 100 (coolcoin#test).
{
Expand All @@ -242,7 +248,7 @@ test.skip(testCase, async (t: Test) => {
t.ok(res);
t.ok(res.data);
t.equal(res.status, 200);
t.equal(res.data.transactionReceipt.status, "COMMITTED");
t.equal(res.data.transactionReceipt.status[0], "COMMITTED");
}

// Iroha1's admin transfers 30 (coolcoin#test) to Iroha2's admin.
Expand All @@ -265,7 +271,7 @@ test.skip(testCase, async (t: Test) => {
t.ok(res);
t.ok(res.data);
t.equal(res.status, 200);
t.equal(res.data.transactionReceipt.status, "COMMITTED");
t.equal(res.data.transactionReceipt.status[0], "COMMITTED");
}
//i.e., Iroha2's admin adds 30 (coolcoin#test).
{
Expand All @@ -286,7 +292,7 @@ test.skip(testCase, async (t: Test) => {
t.ok(res);
t.ok(res.data);
t.equal(res.status, 200);
t.equal(res.data.transactionReceipt.status, "COMMITTED");
t.equal(res.data.transactionReceipt.status[0], "COMMITTED");
}
//Verification: iroha1's admin has 70 (coolcoin#test).
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
KeyPair,
RunTransactionRequestV1,
} from "../../../../main/typescript/generated/openapi/typescript-axios";
import cryptoHelper from "iroha-helpers-ts/lib/cryptoHelper";
import cryptoHelper from "iroha-helpers/lib/cryptoHelper";

import OAS from "../../../../main/json/openapi.json";
import { installOpenapiValidationMiddleware } from "@hyperledger/cactus-core";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
IrohaQuery,
KeyPair,
} from "../../../main/typescript/generated/openapi/typescript-axios";
import cryptoHelper from "iroha-helpers-ts/lib/cryptoHelper";
import cryptoHelper from "iroha-helpers/lib/cryptoHelper";

const testCase = "runs tx on an Iroha v1.2.0 ledger";
const logLevel: LogLevelDesc = "INFO";
Expand Down Expand Up @@ -883,7 +883,7 @@ test.skip(testCase, async (t: Test) => {
timeoutLimit: 5000,
tls: false,
},
params: [userID, "age", "118", "18"], //change age from 18 to 118
params: [userID, "age", "118", "18", true], //change age from 18 to 118
};
const res = await apiClient.runTransactionV1(req);
t.ok(res);
Expand Down
19 changes: 19 additions & 0 deletions patches/iroha-helpers+0.9.3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/node_modules/iroha-helpers/lib/util.js b/node_modules/iroha-helpers/lib/util.js
index 0409412..fd49b69 100644
--- a/node_modules/iroha-helpers/lib/util.js
+++ b/node_modules/iroha-helpers/lib/util.js
@@ -113,11 +113,11 @@ function sendTransactions(txs, txClient, timeoutLimit, requiredStatusesStr) {
.map(function (h) { return _streamVerifier(h, txClient, requiredStatusesStr); });
Promise.all(requests)
.then(function (res) {
- var status = res
- .map(function (r) { return reverseEnum(endpoint_pb_1.TxStatus)[r.tx.getTxStatus()]; });
+ const status = res.map(r => reverseEnum(endpoint_pb_1.TxStatus)[r.tx.getTxStatus()])
+ const hash = res.map(r => r.tx.getTxHash())
return res.some(function (r) { return r.error; })
? reject(new Error("Command response error: expected=" + requiredStatusesStr + ", actual=" + status))
- : resolve();
+ : resolve({ txHash: hash, status: status })
});
});
});
Loading