diff --git a/.github/workflows/test-on-push.yml b/.github/workflows/test-on-push.yml index 92e2ad954..3dff3ed23 100644 --- a/.github/workflows/test-on-push.yml +++ b/.github/workflows/test-on-push.yml @@ -105,6 +105,49 @@ jobs: fi npm run network:prune --prefix ./project-test + template-e2e-rest: + name: Chaincode template E2E (REST API) + runs-on: ubuntu-22.04 + needs: [ci] + env: + GALA_CLIENT_DEV_MODE: "false" + CURATORORG_OPS_API_URL: "http://localhost:8801" + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install tools + run: | + sudo apt-get update + sudo apt-get install -y jq + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 + sudo chmod a+x /usr/local/bin/yq + git --version + node --version + npm --version + jq --version + yq --version + bash --version + docker version + docker-compose version + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install local CLI + run: .github/scripts/install-local-cli.sh + - name: Create test project + run: galachain init ./project-test + - name: Install dependencies + run: | + (cd ./project-test && ../npm-pack-and-replace.sh --skipConfirmation) + npm i --prefix ./project-test + - name: Remove nvm file to avoid Fablo calling it and raising nvm issue with npm_config_prefix env + run: rm ~/.nvm/nvm.sh + - name: Run network in non-watch mode + run: npm run network:up --prefix ./project-test + - name: Run E2E tests + run: npm run test:e2e --prefix ./project-test + template-image-check: name: Chaincode template image check needs: [ci] diff --git a/chain-cli/chaincode-template/api-config.json b/chain-cli/chaincode-template/api-config.json index 6ff6b888b..e014fe84f 100644 --- a/chain-cli/chaincode-template/api-config.json +++ b/chain-cli/chaincode-template/api-config.json @@ -6,21 +6,21 @@ "asLocalHost": true, "contracts": [ { - "pathFragment": "apple", + "pathFragment": "apple-contract", "chaincodeName": "basic-product", "contractName": "AppleContract" }, { - "pathFragment": "public-key-contract", + "pathFragment": "gala-chain-token", "chaincodeName": "basic-product", - "contractName": "PublicKeyContract" + "contractName": "GalaChainToken" }, { - "pathFragment": "token-contract", + "pathFragment": "public-key-contract", "chaincodeName": "basic-product", - "contractName": "GalaChainToken" + "contractName": "PublicKeyContract" } ] } ] -} +} \ No newline at end of file diff --git a/chain-cli/src/commands/network-up/index.ts b/chain-cli/src/commands/network-up/index.ts index 9c0a245a4..2ad806c62 100644 --- a/chain-cli/src/commands/network-up/index.ts +++ b/chain-cli/src/commands/network-up/index.ts @@ -102,7 +102,7 @@ export default class NetworkUp extends BaseCommand { if (flags.contracts) { // This feature supports only a single channel console.log("Overwriting api-config.json with contracts: " + flags.contracts); - overwriteApiConfig(flags.contracts, flags.channel[0], flags.chaincodeName[0]); + await overwriteApiConfig(flags.contracts, flags.channel[0], flags.chaincodeName[0]); } const fabloRoot = path.resolve(flags.fabloRoot); @@ -110,7 +110,7 @@ export default class NetworkUp extends BaseCommand { const localhostName = process.env.LOCALHOST_NAME ?? "localhost"; console.log("Network root directory:", fabloRoot); - await copyNetworkScriptsTo(fabloRoot); + copyNetworkScriptsTo(fabloRoot); const singleArgs = reduce(flags).map((a) => ({ ...a, diff --git a/chain-test/src/e2e/ContractTestClient.ts b/chain-test/src/e2e/ContractTestClient.ts index 5b36b902e..cd6bb65e8 100644 --- a/chain-test/src/e2e/ContractTestClient.ts +++ b/chain-test/src/e2e/ContractTestClient.ts @@ -40,7 +40,8 @@ export function networkRoot() { } function defaultOpsApiConfigPath() { - return path.resolve(networkRoot(), "api-config.json"); + // by default project root is a parent of network root + return path.resolve(networkRoot(), "..", "api-config.json"); } function defaultConnectionProfilePath(orgKey: "curator" | "users" | "partner"): string {