Skip to content

Commit

Permalink
Updated code for quorum part2
Browse files Browse the repository at this point in the history
Signed-off-by: jagpreetsinghsasan <[email protected]>
  • Loading branch information
jagpreetsinghsasan committed Dec 14, 2023
1 parent ac8afaf commit 76e324b
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
PluginLedgerConnectorQuorum,
Web3SigningCredentialType,
DefaultApi as QuorumApi,
DeployContractSolidityBytecodeJsonObjectV1Request,
InvokeContractJsonObjectV1Request,
DeployContractSolidityBytecodeWithoutKeychainV1Request,
InvokeContractWithoutKeychainV1Request,
} from "../../../../../../main/typescript/public-api";

import {
Expand Down Expand Up @@ -131,8 +131,8 @@ test(testCase, async (t: Test) => {
gas: 1000000,
contractJSON: HelloWorldContractJson,
};
const res = await apiClient.deployContractSolBytecodeJsonObjectV1(
parameters as DeployContractSolidityBytecodeJsonObjectV1Request,
const res = await apiClient.deployContractSolBytecodeWithoutKeychainV1(
parameters as DeployContractSolidityBytecodeWithoutKeychainV1Request,
);
t2.ok(res, "Contract deployed successfully");
t2.ok(res.data);
Expand Down Expand Up @@ -161,8 +161,8 @@ test(testCase, async (t: Test) => {
},
contractJSON: HelloWorldContractJson,
};
const res = await apiClient.invokeContractV1NoKeychain(
parameters as InvokeContractJsonObjectV1Request,
const res = await apiClient.invokeContractV1WithoutKeychain(
parameters as InvokeContractWithoutKeychainV1Request,
);
t2.ok(res, "Contract invoked successfully");
t2.ok(res.data);
Expand All @@ -187,8 +187,8 @@ test(testCase, async (t: Test) => {
bytecode: HelloWorldContractJson.bytecode,
gas: 1000000,
};
await apiClient.deployContractSolBytecodeJsonObjectV1(
parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request,
await apiClient.deployContractSolBytecodeWithoutKeychainV1(
parameters as any as DeployContractSolidityBytecodeWithoutKeychainV1Request,
);
} catch (e) {
t2.equal(
Expand Down Expand Up @@ -223,8 +223,8 @@ test(testCase, async (t: Test) => {
contractJSON: HelloWorldContractJson,
fake: 4,
};
await apiClient.deployContractSolBytecodeJsonObjectV1(
parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request,
await apiClient.deployContractSolBytecodeWithoutKeychainV1(
parameters as any as DeployContractSolidityBytecodeWithoutKeychainV1Request,
);
} catch (e) {
t2.equal(
Expand Down Expand Up @@ -259,8 +259,8 @@ test(testCase, async (t: Test) => {
},
nonce: 2,
};
await apiClient.invokeContractV1NoKeychain(
parameters as any as InvokeContractJsonObjectV1Request,
await apiClient.invokeContractV1WithoutKeychain(
parameters as any as InvokeContractWithoutKeychainV1Request,
);
} catch (e) {
t2.equal(
Expand Down Expand Up @@ -298,8 +298,8 @@ test(testCase, async (t: Test) => {
contractJSON: HelloWorldContractJson,
fake: 4,
};
await apiClient.invokeContractV1NoKeychain(
parameters as any as InvokeContractJsonObjectV1Request,
await apiClient.invokeContractV1WithoutKeychain(
parameters as any as InvokeContractWithoutKeychainV1Request,
);
} catch (e) {
t2.equal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
let contractAddress: string;

test("deploys contract via .json file", async (t2: Test) => {
const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({
web3SigningCredential: {
ethAccount: firstHighNetWorthAccount,
secret: "",
type: Web3SigningCredentialType.GethKeychainPassword,
},
gas: 1000000,
contractJSON: HelloWorldContractJson,
});
const deployOut =
await apiClient.deployContractSolBytecodeWithoutKeychainV1({
web3SigningCredential: {
ethAccount: firstHighNetWorthAccount,
secret: "",
type: Web3SigningCredentialType.GethKeychainPassword,
},
gas: 1000000,
contractJSON: HelloWorldContractJson,
});
t2.ok(deployOut, "deployContract() output is truthy OK");
t2.ok(
deployOut.data.transactionReceipt,
Expand All @@ -141,7 +142,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
"contractAddress typeof string OK",
);

const helloMsgRes = await apiClient.invokeContractV1NoKeychain({
const helloMsgRes = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Call,
methodName: "sayHello",
Expand All @@ -166,7 +167,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
const txCount = await web3.eth.getTransactionCount(
firstHighNetWorthAccount,
);
const setNameOut = await apiClient.invokeContractV1NoKeychain({
const setNameOut = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "setName",
Expand All @@ -183,20 +184,22 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
t2.ok(setNameOut, "setName() invocation #1 output is truthy OK");

try {
const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "setName",
params: [newName],
gas: 1000000,
web3SigningCredential: {
ethAccount: firstHighNetWorthAccount,
secret: "",
type: Web3SigningCredentialType.GethKeychainPassword,
const setNameOutInvalid = await apiClient.invokeContractV1WithoutKeychain(
{
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "setName",
params: [newName],
gas: 1000000,
web3SigningCredential: {
ethAccount: firstHighNetWorthAccount,
secret: "",
type: Web3SigningCredentialType.GethKeychainPassword,
},
nonce: 2,
contractJSON: HelloWorldContractJson,
},
nonce: 2,
contractJSON: HelloWorldContractJson,
});
);
t2.ifError(setNameOutInvalid.data.transactionReceipt);
} catch (error) {
t2.notStrictEqual(
Expand All @@ -206,7 +209,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
);
}

const getNameOut = await apiClient.invokeContractV1NoKeychain({
const getNameOut = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "getName",
Expand All @@ -224,7 +227,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
`getName() SEND invocation produced receipt OK`,
);

const getNameOut2 = await apiClient.invokeContractV1NoKeychain({
const getNameOut2 = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Call,
methodName: "getName",
Expand Down Expand Up @@ -276,7 +279,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {

test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => {
const newName = `DrCactus${uuidV4()}`;
const setNameOut = await apiClient.invokeContractV1NoKeychain({
const setNameOut = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "setName",
Expand All @@ -293,20 +296,22 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
t2.ok(setNameOut, "setName() invocation #1 output is truthy OK");

try {
const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "setName",
params: [newName],
gas: 1000000,
web3SigningCredential: {
ethAccount: testEthAccount.address,
secret: testEthAccount.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
const setNameOutInvalid = await apiClient.invokeContractV1WithoutKeychain(
{
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "setName",
params: [newName],
gas: 1000000,
web3SigningCredential: {
ethAccount: testEthAccount.address,
secret: testEthAccount.privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
},
nonce: 1,
contractJSON: HelloWorldContractJson,
},
nonce: 1,
contractJSON: HelloWorldContractJson,
});
);
t2.ifError(setNameOutInvalid.data.transactionReceipt);
} catch (error) {
t2.notStrictEqual(
Expand All @@ -316,7 +321,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
);
}

const getNameOut = await apiClient.invokeContractV1NoKeychain({
const getNameOut = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Call,
methodName: "getName",
Expand All @@ -335,7 +340,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
`getName() output reflects the update OK`,
);

const getNameOut2 = await apiClient.invokeContractV1NoKeychain({
const getNameOut2 = await apiClient.invokeContractV1WithoutKeychain({
contractAddress,
invocationType: EthContractInvocationType.Send,
methodName: "getName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {
let contractAddress: string;

test("deploys contract via .json file", async (t2: Test) => {
const deployOut = await connector.deployContractJsonObject({
const deployOut = await connector.deployContractWithoutKeychain({
web3SigningCredential: {
ethAccount: firstHighNetWorthAccount,
secret: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test(testCase, async (t: Test) => {
let contractAddress: string;

test("deploys contract via .json file", async (t2: Test) => {
const deployOut = await connector.deployContractJsonObject({
const deployOut = await connector.deployContractWithoutKeychain({
web3SigningCredential: {
ethAccount: firstHighNetWorthAccount,
secret: "",
Expand Down
Loading

0 comments on commit 76e324b

Please sign in to comment.