Skip to content

Commit

Permalink
works hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
acharb committed Nov 22, 2023
1 parent 05c54d1 commit b0bd2ef
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 132 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/integrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!-- ALEC TODO - add directions for running integration tests locally -->
97 changes: 0 additions & 97 deletions docker-compose-sandbox.yml

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module.exports = {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
testPathIgnorePatterns: ["/node_modules/", "integration.test.ts"],
};
9 changes: 9 additions & 0 deletions jest.integration.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
rootDir: "./",
preset: "ts-jest",
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
testMatch: ["**/*integration.test.ts"],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
36 changes: 5 additions & 31 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -104,17 +97,16 @@ describe("ALEC TODO", () => {
};
const recoverableWallet = await recovery.createRecoverableWallet(config);

console.log({ recoverableWallet }); // ALEC TODO - remove

// Sign and submit

recoverableWallet.transaction.sign(accountKp.keypair);
await stellar.submitTransaction(recoverableWallet.transaction);

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);
Expand All @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit b0bd2ef

Please sign in to comment.