Skip to content

Commit

Permalink
feat(connector-besu,connector-quorum): updated
Browse files Browse the repository at this point in the history
Signed-off-by: AzaharaC <a.castano.benito@accenture.com>
  • Loading branch information
AzaharaC authored and petermetz committed Apr 23, 2021
1 parent c79d763 commit 985f12f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ export class PluginLedgerConnectorBesu
contractJSON.networks[networkId].address,
);
this.contracts[contractName] = contract;
} else {
} else if (
req.keychainId == undefined &&
req.contractAbi == undefined &&
req.contractAddress == undefined
) {
throw new Error(
`${fnTag} Cannot invoke a contract without contract instance, the keychainId param is needed`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ test(testCase, async (t: Test) => {
);

const { callOutput: helloMsg } = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.CALL,
Expand Down Expand Up @@ -218,6 +219,7 @@ test(testCase, async (t: Test) => {
test("invoke Web3SigningCredentialType.PRIVATEKEYHEX", async (t2: Test) => {
const newName = `DrCactus${uuidv4()}`;
const setNameOut = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -234,6 +236,7 @@ test(testCase, async (t: Test) => {

try {
const setNameOutInvalid = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -256,6 +259,7 @@ test(testCase, async (t: Test) => {
);
}
const { callOutput: getNameOut } = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.CALL,
Expand All @@ -271,6 +275,7 @@ test(testCase, async (t: Test) => {
t2.equal(getNameOut, newName, `getName() output reflects the update OK`);

const getNameOut2 = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -286,6 +291,7 @@ test(testCase, async (t: Test) => {
t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK");

const response = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -302,6 +308,7 @@ test(testCase, async (t: Test) => {
t2.ok(response, "deposit() payable invocation output is truthy OK");

const { callOutput } = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.CALL,
Expand Down Expand Up @@ -334,6 +341,7 @@ test(testCase, async (t: Test) => {
};

const setNameOut = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -347,6 +355,7 @@ test(testCase, async (t: Test) => {

try {
const setNameOutInvalid = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -366,6 +375,7 @@ test(testCase, async (t: Test) => {
}

const { callOutput: getNameOut } = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.CALL,
Expand All @@ -377,6 +387,7 @@ test(testCase, async (t: Test) => {
t2.equal(getNameOut, newName, `getName() output reflects the update OK`);

const getNameOut2 = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -388,6 +399,7 @@ test(testCase, async (t: Test) => {
t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK");

const response = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.SEND,
Expand All @@ -400,6 +412,7 @@ test(testCase, async (t: Test) => {
t2.ok(response, "deposit() payable invocation output is truthy OK");

const { callOutput } = await connector.invokeContract({
contractName: HelloWorldContractJson.contractName,
contractAbi: HelloWorldContractJson.abi,
contractAddress,
invocationType: EthContractInvocationType.CALL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class PluginLedgerConnectorQuorum
): Promise<InvokeContractV1Response> {
const fnTag = `${this.className}#invokeContract()`;
const contractName = req.contractName;
let contractInstance: Contract;
let contractInstance: InstanceType<typeof Contract>;

if (req.keychainId != undefined) {
const networkId = await this.web3.eth.net.getId();
Expand Down Expand Up @@ -262,7 +262,11 @@ export class PluginLedgerConnectorQuorum
contractJSON.networks[networkId].address,
);
this.contracts[contractName] = contract;
} else {
} else if (
req.keychainId == undefined &&
req.contractAbi == undefined &&
req.contractAddress == undefined
) {
throw new Error(
`${fnTag} Cannot invoke a contract without contract instance, the keychainId param is needed`,
);
Expand Down

0 comments on commit 985f12f

Please sign in to comment.