diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 2d6d20c..b81a100 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -7,14 +7,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: Start docker - run: docker-compose -f docker-compose.yml up -d + run: docker-compose -f test/docker/docker-compose.yml up -d - uses: actions/setup-node@v2 with: node-version: 18 - run: yarn install - run: yarn build - - run: yarn test:integration - # ALEC TODO - remove below probably + - run: yarn test:integration:ci - name: Print Docker Logs if: always() # This ensures that the logs are printed even if the tests fail run: docker-compose logs diff --git a/README.md b/README.md index 00de879..ac26048 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,5 @@ const authToken = await sep10.authenticate({ accountKp: authKey }); Read [full wallet guide](https://developers.stellar.org/docs/category/build-a-wallet-with-the-wallet-sdk) for more info + + diff --git a/docker-compose-sandbox.yml b/docker-compose-sandbox.yml deleted file mode 100644 index 2402822..0000000 --- a/docker-compose-sandbox.yml +++ /dev/null @@ -1,97 +0,0 @@ -version: "3" -services: - recovery-signer-migrate1: - image: stellar/recoverysigner - depends_on: - postgres1: - condition: service_healthy - restart: on-failure - command: ["db", "migrate", "up"] - environment: - DB_URL: "postgresql://postgres:pg_password@postgres1:5432/pg_database1?sslmode=disable" - - recovery-signer-migrate2: - image: stellar/recoverysigner - depends_on: - postgres2: - condition: service_healthy - restart: on-failure - command: ["db", "migrate", "up"] - environment: - DB_URL: "postgresql://postgres:pg_password@postgres2:5432/pg_database2?sslmode=disable" - - recovery-signer1: - image: stellar/recoverysigner - ports: - - "8000:8000" - depends_on: - - postgres1 - environment: - DB_URL: "postgresql://postgres:pg_password@postgres1:5432/pg_database1?sslmode=disable" - SIGNING_KEY: SAQFNCKPZ3ON5TSSEURAF4NPTZONPA37JPHQNHSLSRUNFP43MMT5LNH6 - FIREBASE_PROJECT_ID: "none" - SEP10_JWKS: '{"keys":[{"kty":"EC","crv":"P-256","alg":"ES256","x":"dzqvhrMYwbmv7kcZK6L1oOATMFXG9wLFlnKfHf3E7FM","y":"Vb_wmcX-Zq2Hg2LFoXCEVWMwdJ01q41pSnxC3psunUY"}]}' - PORT: 8000 - - recovery-signer2: - image: stellar/recoverysigner - ports: - - "8002:8002" - depends_on: - - postgres2 - environment: - DB_URL: "postgresql://postgres:pg_password@postgres2:5432/pg_database2?sslmode=disable" - SIGNING_KEY: SA3Y2KQCPN6RAKLUISMY252QABWPQ3A65FBMZO2JJFKJ7O7VJNQ2PRYH # Use a different key for the second recovery signer - FIREBASE_PROJECT_ID: "none" - SEP10_JWKS: '{"keys":[{"kty":"EC","crv":"P-256","alg":"ES256","x":"dzqvhrMYwbmv7kcZK6L1oOATMFXG9wLFlnKfHf3E7FM","y":"Vb_wmcX-Zq2Hg2LFoXCEVWMwdJ01q41pSnxC3psunUY"}]}' - PORT: 8002 - - web-auth1: - image: stellar/webauth - ports: - - "8001:8001" - environment: - SIGNING_KEY: SDYHSG4V2JP5H66N2CXBFCOBTAUFWXGJVPKWY6OXSIPMYW743N62QX6U - JWK: '{"kty":"EC","crv":"P-256","alg":"ES256","x":"dzqvhrMYwbmv7kcZK6L1oOATMFXG9wLFlnKfHf3E7FM","y":"Vb_wmcX-Zq2Hg2LFoXCEVWMwdJ01q41pSnxC3psunUY","d":"ivOMB4Wscz8ShvhwWDRyd-JJVfSMsjsz1oU3sNc-XJo"}' - DOMAIN: test-domain - AUTH_HOME_DOMAIN: test-domain - JWT_ISSUER: test - PORT: 8001 - - web-auth2: - image: stellar/webauth - ports: - - "8003:8003" - environment: - SIGNING_KEY: SCAS7BUKVDL44A2BAP23RVAM6XXHB24YRCANQGDTP24HP7T6LPUFIGGU # Use a different key for the second web auth server - JWK: '{"kty":"EC","crv":"P-256","alg":"ES256","x":"dzqvhrMYwbmv7kcZK6L1oOATMFXG9wLFlnKfHf3E7FM","y":"Vb_wmcX-Zq2Hg2LFoXCEVWMwdJ01q41pSnxC3psunUY","d":"ivOMB4Wscz8ShvhwWDRyd-JJVfSMsjsz1oU3sNc-XJo"}' - DOMAIN: test-domain - AUTH_HOME_DOMAIN: test-domain - JWT_ISSUER: test - PORT: 8003 - - postgres1: - image: postgres - environment: - POSTGRES_PASSWORD: pg_password - POSTGRES_DB: pg_database1 - ports: - - "5432:5432" - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] - interval: 10s - timeout: 5s - retries: 5 - - postgres2: - image: postgres - environment: - POSTGRES_PASSWORD: pg_password - POSTGRES_DB: pg_database2 - ports: - - "5433:5432" - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] - interval: 10s - timeout: 5s - retries: 5 diff --git a/jest.config.js b/jest.config.js index 5191e9f..e4180ff 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,4 +5,5 @@ module.exports = { "^.+\\.(ts|tsx)?$": "ts-jest", "^.+\\.(js|jsx)$": "babel-jest", }, + testPathIgnorePatterns: ["/node_modules/", "integration.test.ts"], }; diff --git a/jest.integration.config.js b/jest.integration.config.js new file mode 100644 index 0000000..bc33dbf --- /dev/null +++ b/jest.integration.config.js @@ -0,0 +1,9 @@ +module.exports = { + rootDir: "./", + preset: "ts-jest", + transform: { + "^.+\\.(ts|tsx)?$": "ts-jest", + "^.+\\.(js|jsx)$": "babel-jest", + }, + testMatch: ["**/*integration.test.ts"], +}; diff --git a/package.json b/package.json index a1e54bd..13137d9 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "prepare": "husky install", "test": "jest --watchAll", "test:ci": "jest --ci", - "test:integration": "jest -t 'ALEC TODO'", + "test:integration:ci": "jest --config jest.integration.config.js --ci", "build:web": "webpack --config webpack.config.js", "build:node": "webpack --env NODE=true --config webpack.config.js", "build": "run-p build:web build:node", diff --git a/docker-compose.yml b/test/docker/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to test/docker/docker-compose.yml diff --git a/test/integration.test.ts b/test/integration.test.ts index 4692fb4..3a8e47e 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -11,9 +11,7 @@ import { RecoveryType, } from "../src/walletSdk/Types/recovery"; -// ALEC TODO - move these tests? how to automate? - -describe("ALEC TODO", () => { +describe("Recovery Integration Tests", () => { it("should work", async () => { const wallet = Wallet.TestNet(); const stellar = wallet.stellar(); @@ -41,16 +39,11 @@ describe("ALEC TODO", () => { const recovery = wallet.recovery({ servers }); // Create accounts - const accountKp = accountService.createKeypair(); - console.log("accountKp:", accountKp.publicKey); // ALEC TODO - remove + const accountKp = accountService.createKeypair(); const deviceKp = accountService.createKeypair(); - console.log("deviceKp:", deviceKp.publicKey); // ALEC TODO - remove - const recoveryKp = accountService.createKeypair(); - console.log("recoveryKp:", recoveryKp.publicKey); // ALEC TODO - remove - // Make sure exists try { await stellar.server.loadAccount(accountKp.publicKey); await stellar.server.loadAccount(deviceKp.publicKey); @@ -104,8 +97,6 @@ describe("ALEC TODO", () => { }; const recoverableWallet = await recovery.createRecoverableWallet(config); - console.log({ recoverableWallet }); // ALEC TODO - remove - // Sign and submit recoverableWallet.transaction.sign(accountKp.keypair); @@ -113,8 +104,9 @@ describe("ALEC TODO", () => { let resp = await stellar.server.loadAccount(accountKp.publicKey); - // ALEC TODO - uncomment, ignore order of array - // expect(resp.signers.map((obj) => obj.weight)).toEqual([5, 5, 10, 0]); + expect(resp.signers.map((obj) => obj.weight).sort((a, b) => a - b)).toEqual( + [0, 5, 5, 10], + ); expect( resp.signers.find((obj) => obj.key === accountKp.publicKey).weight, ).toBe(0); @@ -135,22 +127,6 @@ describe("ALEC TODO", () => { expect(accountResp[server1Key].identities[0].role).toBe("owner"); expect(accountResp[server1Key].signers.length).toBe(1); - console.log({ accountResp }); // ALEC TODO - remove - console.log(accountResp.server1.identities); // ALEC TODO - remove - console.log(accountResp.server1.signers); // ALEC TODO - remove - - // ALEC TODO - remove - // const authToken2 = await recovery - // .sep10Auth(server2Key) - // .authenticate({ accountKp: recoveryKp }); - - // const authMap2 = { [server2Key]: authToken2 }; - - // const accountResp2 = await recovery.getAccountInfo(accountKp, authMap2); - // console.log({ accountResp2 }); // ALEC TODO - remove - // console.log(accountResp2.server2.identities); // ALEC TODO - remove - // console.log(accountResp2.server2.signers); // ALEC TODO - remove - // Recover Wallet const authToken2 = await recovery @@ -176,8 +152,6 @@ describe("ALEC TODO", () => { signerMap, ); - console.log(recoverTxn.toXDR()); // ALEC TODO - remove - await stellar.submitTransaction(recoverTxn); resp = await stellar.server.loadAccount(accountKp.publicKey);