Skip to content

Commit

Permalink
style(docs/examples/cbdc): applied auto-formatting to CBDC example code
Browse files Browse the repository at this point in the history
Just ran `yarn lint` on `main` and it applied these formatting changes
so I'm applying the changes to make sure others don't have to deal with
the auto-formatter littering their commits with automated changes like
these.

The bigger story here is that this somehow passed the CI which makes me
suspect that we forgot to add a check to the lint action that would
verify that post-lint there are no files changed compared to the git
revision that is being linted, so figuring this out is a to-do still and
should go into it's own pull request later on.

Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
petermetz committed Mar 4, 2024
1 parent f02a0aa commit 2d8d23f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
} from "../besu-helper";
import AssetReferenceContractJson from "../../../../solidity/asset-reference-contract/AssetReferenceContract.json";
import CBDCcontractJson from "../../../../solidity/cbdc-erc-20/CBDCcontract.json";
import { getEthAddress, getPrvKey, assertEqual, assertStringContains } from "./common";
import {
getEthAddress,
getPrvKey,
assertEqual,
assertStringContains,
} from "./common";

const BESU_CONTRACT_CBDC_ERC20_NAME = CBDCcontractJson.contractName;
const BESU_CONTRACT_ASSET_REF_NAME = AssetReferenceContractJson.contractName;
Expand Down Expand Up @@ -156,7 +161,8 @@ Then(
getPrvKey(user),
assetRefID,
).catch((err) => {
assertStringContains(err.response.data.error,
assertStringContains(
err.response.data.error,
`Transaction has been reverted by the EVM`,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ Then(
Then(
"{string} fails to initiate bridge back of {int} CBDC referenced by id {string}",
{ timeout: 60 * 1000 },
async function (
user: string,
amount: number,
assetRefID: string,
) {
async function (user: string, amount: number, assetRefID: string) {
const address = getEthAddress(user);
const fabricID = getFabricId(user);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { When, Then } from "cucumber";
import axios from "axios";
import CryptoMaterial from "../../../../crypto-material/crypto-material.json";
import { getUserFromPseudonim, getFabricId, getEthAddress, assertEqual, assertStringContains } from "./common";
import {
getUserFromPseudonim,
getFabricId,
getEthAddress,
assertEqual,
assertStringContains,
} from "./common";

const MAX_RETRIES = 5;
const MAX_TIMEOUT = 5000;
Expand Down Expand Up @@ -87,7 +93,7 @@ When(
recipientLedgerAssetID: "FABRIC_ASSET_ID",
},
);

assertEqual(response.status, 200);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ export function getPrvKey(user: string): string {
}
}

export function assertEqual(
value_1: unknown,
value_2: unknown,
) {
export function assertEqual(value_1: unknown, value_2: unknown) {
if (value_1 !== value_2) {
throw Error(`Expected ${value_1} to be equal to ${value_2}`);
}
Expand All @@ -66,7 +63,7 @@ export function assertStringContains(
subString: string,
): void {
if (!mainString.includes(subString)) {
throw new Error(`String "${mainString}" does not contain "${subString}"`);
throw new Error(`String "${mainString}" does not contain "${subString}"`);
}
}

Expand All @@ -76,4 +73,4 @@ export function assertNonNullish<TValue>(
if (value === null || value === undefined) {
throw Error(`${value} was expected to be non-null`);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getUserFromPseudonim,
assertEqual,
assertNonNullish,
assertStringContains
assertStringContains,
} from "./common";
import {
deleteFabricAssetReference,
Expand Down Expand Up @@ -94,7 +94,7 @@ When(

When(
"bob refunds {int} CBDC to {string} in the source chain",
{ timeout: 10 * 1000 },
{ timeout: 10 * 1000 },
async function (amount: number, userTo: string) {
const finalUserFabricID = getFabricId(userTo);
const finalUserEthAddress = getEthAddress(userTo);
Expand Down Expand Up @@ -123,14 +123,17 @@ Then(
},
)
.catch((err) => {
assertStringContains(err.response.data.error, `client is not authorized to perform the operation`);
assertStringContains(
err.response.data.error,
`client is not authorized to perform the operation`,
);
});
},
);

Then(
"{string} fails to transfer {int} CBDC to {string}",
{ timeout: 10 * 1000 },
{ timeout: 10 * 1000 },
async function (userFrom: string, amount: number, userTo: string) {
const recipient = getFabricId(userTo);

Expand All @@ -157,32 +160,32 @@ Then(

Then(
"{string} has {int} CBDC available in the source chain",
{ timeout: 10 * 1000 },
{ timeout: 10 * 1000 },
async function (user: string, amount: number) {
assertEqual((await getFabricBalance(getFabricId(user))), amount)
assertEqual(await getFabricBalance(getFabricId(user)), amount);
},
);

Then(
"the asset reference chaincode has an asset reference with id {string}",
{ timeout: 10 * 1000 },
{ timeout: 10 * 1000 },
async function (assetRefID: string) {
assertNonNullish((await readFabricAssetReference(assetRefID)));
assertNonNullish(await readFabricAssetReference(assetRefID));
},
);

Then(
"the asset reference with id {string} is locked in the source chain",
{ timeout: 10 * 1000 },
{ timeout: 10 * 1000 },
async function (assetRefID: string) {
assertEqual((await readFabricAssetReference(assetRefID)).isLocked, true)
assertEqual((await readFabricAssetReference(assetRefID)).isLocked, true);
},
);

Then(
"the asset reference chaincode has no asset reference with id {string}",
{ timeout: 10 * 1000 },
{ timeout: 10 * 1000 },
async function (assetRefID: string) {
assertEqual(await fabricAssetReferenceExists(assetRefID), "false")
assertEqual(await fabricAssetReferenceExists(assetRefID), "false");
},
);

0 comments on commit 2d8d23f

Please sign in to comment.