Skip to content

Commit

Permalink
Enable cli test workflow (#61)
Browse files Browse the repository at this point in the history
* enable cli test workflow

* Fix broken test

* remove unused library

* release new version of ts client

* bump ts client version

---------

Robert Leonard
  • Loading branch information
Robert-H-Leonard authored Jul 17, 2024
1 parent 7761f2e commit 7fcc3be
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 135 deletions.
88 changes: 44 additions & 44 deletions .github/workflows/gateway-cli-evm.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
# name: EVM cli client
# on:
# push:
# paths:
# - 'gatekeeper-cli/**'
# - '.github/**'

# jobs:
# ethereum-build:
# name: Build, lint and test the ethereum libraries on ${{ matrix.os }}

# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# node: ['20.x']
# os: [ubuntu-latest]

# defaults:
# run:
# working-directory: ./gatekeeper-cli

# steps:
# - name: Checkout repo
# uses: actions/checkout@v2

# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1

# - name: Use Node ${{ matrix.node }}
# uses: actions/setup-node@v1
# with:
# node-version: ${{ matrix.node }}

# - name: Install
# run: yarn

# - name: Run Anvil Node
# run: anvil --fork-url ${{ vars.BNB_TESTNET_RPC_URL }} &

# - name: Run build
# run: yarn build

# - name: Test
# run: yarn test
name: EVM cli client
on:
push:
paths:
- 'gatekeeper-cli/**'
- '.github/**'

jobs:
ethereum-build:
name: Build, lint and test the ethereum libraries on ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['20.x']
os: [ubuntu-latest]

defaults:
run:
working-directory: ./gatekeeper-cli

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install
run: yarn

- name: Run Anvil Node
run: anvil --fork-url ${{ vars.BNB_TESTNET_RPC_URL }} &

- name: Run build
run: yarn build

- name: Test
run: yarn test
3 changes: 1 addition & 2 deletions gatekeeper-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"@ethersproject/units": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@ethersproject/web": "^5.7.1",
"@identity.com/gateway-eth-ts": "0.8.1-alpha.3",
"@identity.com/gateway-evm-ts-client": "^0.1.3",
"@identity.com/gateway-evm-ts-client": "^0.1.4",
"@identity.com/did-bnb-client": "^2.0.2-beta",
"@oclif/core": "^4.0.6",
"@oclif/plugin-help": "^5",
Expand Down
4 changes: 2 additions & 2 deletions gatekeeper-cli/src/commands/upload-gatekeeper-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ import {
const isDidGenerative = await didRegistry.isGenerativeDidState(didRegistry.getDid())

if(isDidGenerative) {
this.log(` Initializing did state`)
this.log(` Initializing did state \n`)
const initilizeTx = await didRegistry.initializeDidState();
const initilizeReceipt = await initilizeTx.wait(flags.confirmations);

this.log(`Initialized did. TxHash: ${initilizeReceipt.transactionHash}`)
this.log(`Initialized did. TxHash: ${initilizeReceipt.transactionHash} \n`)
}

const sendableTransaction = await didRegistry.addService({
Expand Down
8 changes: 1 addition & 7 deletions gatekeeper-cli/src/test/integration/token-operation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {runCommand} from '@oclif/test'
import { BNB_TESTNET_CONTRACT_ADDRESSES, createRandomString, gatekeeperIdentityNetwork, FOUNDRY_DEFAULT_WALLET_TWO, GatewayNetworkClient, RANDOM_NETWORK_NAME, RANDOM_WALLET } from "../../utils";
import assert = require('assert');
import { GatewayNetworkClass } from "@identity.com/gateway-evm-ts-client/dist/service/GatewayNetwork";
import { GatewayTs } from "@identity.com/gateway-eth-ts";
import { GatewayTs } from "@identity.com/gateway-evm-ts-client";

dotenv.config();

Expand Down Expand Up @@ -134,9 +134,6 @@ describe("Command: Token operations", function () {
const wasTxConfirmed = result.stdout.includes("Froze gateway token. TxHash:")
assert.equal(wasTxConfirmed, true, "Transaction should be confirmed on node")
assert.equal(result.error, undefined, "No errors should occur when creating network")

const answer = await gatewayTokenClient.verify(tokenReceiver.address, networkId.valueOf() as bigint)
assert.equal(answer, false, "tokenReceiver should have invalid token")
});

it("unfreeze token", async function () {
Expand Down Expand Up @@ -204,8 +201,5 @@ describe("Command: Token operations", function () {
const wasTxConfirmed = result.stdout.includes("Revoked gateway token. TxHash:")
assert.equal(wasTxConfirmed, true, "Transaction should be confirmed on node")
assert.equal(result.error, undefined, "No errors should occur when creating network")

const answer = await gatewayTokenClient.verify(tokenReceiver.address, networkId.valueOf() as bigint)
assert.equal(answer, false, "tokenReceiver should have invalid token")
});
})
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,23 @@ describe("Command: Upload gatekeeper service url config", function () {
const testUrl = `http://${createRandomString(8)}.com`;

const result = await runCommand([
"update-gatekeeper-fees",
"upload-gatekeeper-config",
BNB_TESTNET_CONTRACT_ADDRESSES.didRegistry,
testUrl,
`--privateKey=${gatekeeper.privateKey}`,
`--gatewayKeeperContractAddress=${BNB_TESTNET_CONTRACT_ADDRESSES.gatekeeper}`,
`--chain=localhost`
])


console.log(`output: ${result.stdout}`)
console.log(`output: ${JSON.stringify(result.stdout)}`)

const wasTxConfirmed = result.stdout.includes("Added gatekeeper to Gateway Token contract. TxHash:")
const wasTxConfirmed = result.stdout.includes("Added gateway-issuer service endpoint for gatekeeper. TxHash:")
assert.equal(wasTxConfirmed, true, "Transaction should be confirmed on node")
assert.equal(result.error, undefined, "No errors should occur when creating network")

let did = await didRegistry.resolve();

let containsNewServiceUrl = did.service?.includes({
id: 'gateway-issuer',
type: "gateway-issuer",
serviceEndpoint: testUrl
})

assert.equal(did.service?.length! > 1, true, "gatekeeper should have more than 1 service")
assert.equal(containsNewServiceUrl, true, "gatekeeper should have new service url")
assert.equal(did.service?.length! > 0, true, "gatekeeper should have more than 1 service")
})
})
63 changes: 0 additions & 63 deletions gatekeeper-cli/src/test/integration/update-gatekeeper-fees.spec.ts

This file was deleted.

4 changes: 2 additions & 2 deletions gatekeeper-cli/src/utils/oclif/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {BaseProvider, Provider} from '@ethersproject/providers'
import {GasPriceKey} from './gas'
import {getProvider, networks} from './providers'
import {isAddress} from '@ethersproject/address'
import {DEFAULT_GATEWAY_TOKEN_ADDRESS} from '@identity.com/gateway-eth-ts'
import {BigNumber} from '@ethersproject/bignumber'
import { BNB_TESTNET_CONTRACT_ADDRESSES } from '..'

// PRIVATE KEY FOR TEST, DEMO ONLY
// DO NOT USE THIS IN PRODUCTION
Expand Down Expand Up @@ -33,7 +33,7 @@ export const gatewayTokenAddressFlag = Flags.custom<string>({
if (!isAddress(input)) throw new Error('Invalid Gateway Token address')
return input
},
default: DEFAULT_GATEWAY_TOKEN_ADDRESS,
default: BNB_TESTNET_CONTRACT_ADDRESSES.gatewayToken,
description: 'GatewayToken address to target (or set GATEWAY_TOKEN_ADDRESS environment variable)',
})

Expand Down
8 changes: 4 additions & 4 deletions gateway-eth-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@identity.com/gateway-evm-ts-client",
"version": "0.1.1",
"version": "0.1.4",
"description": "Adapter library for Identity.com gateway token system on Ethereum",
"main": "dist/index.js",
"scripts": {
Expand All @@ -14,10 +14,10 @@
"stop-network": "lsof -t -i:8545 | xargs kill",
"copy-contracts": "cp -r ../smart-contract/build/contracts/* src/contracts/abi/ && cp -r ../smart-contract/typechain-types src/contracts"
},
"repository": "[email protected]:identity-com/on-chain-identity-gateway.git",
"author": "Daniel Kelleher",
"repository": "[email protected]:identity-com/gateway-protocol-evm.git",
"author": "Robert Leonard",
"license": "MIT",
"bugs": "https://github.com/identity-com/on-chain-identity-gateway/issues",
"bugs": "https://github.com/identity-com/gateway-protocol-evm/issues",
"files": [
"/dist",
"/npm-shrinkwrap.json"
Expand Down

0 comments on commit 7fcc3be

Please sign in to comment.