Skip to content

Commit

Permalink
Merge branch 'main' into 4-connect-a-wallet-to-the-api-and-add-a-tran…
Browse files Browse the repository at this point in the history
…sfer-function
  • Loading branch information
marc-aurele-besner committed Jun 6, 2024
2 parents d746e6a + 0252e96 commit 3461f13
Show file tree
Hide file tree
Showing 21 changed files with 5,889 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.2.2.cjs
Binary file removed bun.lockb
Binary file not shown.
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
"packages/*"
],
"scripts": {
"build": "bun run --filter '*' build",
"test": "bun run --filter '*' test"
"build": "yarn workspaces foreach --all run build",
"clean": "yarn workspaces foreach --all run clean",
"format": "yarn workspaces foreach --all run format",
"test": "yarn workspaces foreach --all run test"
},
"packageManager": "[email protected]",
"packageManager": "[email protected]",
"engines": {
"node": ">=18.0.0"
},
Expand All @@ -23,11 +25,11 @@
"url": "https://www.autonomys.net"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"typescript": "^5.4.5",
"ts-jest": "^29.1.4",
"@types/jest": "^29.5.12",
"jest": "^29.7.0"
"typescript": "^5.4.5"
}
}
60 changes: 36 additions & 24 deletions packages/auto-consensus/__test__/balances.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { NetworkInput } from '@autonomys/auto-utils'
import { activate, activateWallet, disconnect, networks } from '@autonomys/auto-utils'
import {
ActivateWalletInput,
activate,
activateWallet,
disconnect,
networks,
} from '@autonomys/auto-utils'
import { address } from '../src/address'
import { balance, totalIssuance, transfer } from '../src/balances'

Expand All @@ -23,9 +29,9 @@ describe('Verify balances functions', () => {
await activate(TEST_NETWORK)
})

afterAll(async () => {
await disconnect()
})
// afterAll(async () => {
// await disconnect()
// })

describe('Test totalIssuance()', () => {
test('Check totalIssuance return a number greater than zero', async () => {
Expand All @@ -43,7 +49,7 @@ describe('Verify balances functions', () => {
const { api, accounts } = await activateWallet({
...TEST_NETWORK,
mnemonic: TEST_MNEMONIC,
})
} as ActivateWalletInput)
expect(accounts.length).toBeGreaterThan(0)
expect(accounts[0].address).toEqual(TEST_ADDRESS)

Expand All @@ -56,7 +62,7 @@ describe('Verify balances functions', () => {
const { api, accounts } = await activateWallet({
...TEST_NETWORK,
uri: ALICE_URI,
})
} as ActivateWalletInput)
expect(accounts.length).toBeGreaterThan(0)
expect(accounts[0].address).toEqual(ALICE_ADDRESS)

Expand All @@ -72,7 +78,7 @@ describe('Verify balances functions', () => {
const { api, accounts } = await activateWallet({
...TEST_NETWORK,
uri: ALICE_URI,
})
} as ActivateWalletInput)
expect(accounts.length).toBeGreaterThan(0)
expect(accounts[0].address).toEqual(ALICE_ADDRESS)

Expand All @@ -91,7 +97,12 @@ describe('Verify balances functions', () => {
txHash = status.asInBlock.toHex()
console.log('Successful transfer of 1 with hash ' + txHash)
resolve()
} else if (status.isError) {
} else if (
status.isRetracted ||
status.isFinalityTimeout ||
status.isDropped ||
status.isInvalid
) {
reject(new Error('Transaction failed'))
} else {
console.log('Status of transfer: ' + status.type)
Expand All @@ -108,21 +119,22 @@ describe('Verify balances functions', () => {
})
}

test('Check transfer 1 ATC between Test wallet and Alice should fail (no balance)', async () => {
const { api, accounts } = await activateWallet({
...TEST_NETWORK,
mnemonic: TEST_MNEMONIC,
})
expect(accounts.length).toBeGreaterThan(0)
expect(accounts[0].address).toEqual(TEST_ADDRESS)

const sender = accounts[0]
const tx = await transfer(api, ALICE_ADDRESS, 1)

expect(() => tx.signAndSend(sender)).toThrow(
'Unreachable code should not be executed (evaluating',
// To-Do: Confirm this is the expected error message
)
})
// To-Do: Fix this test
// test('Check transfer 1 ATC between Test wallet and Alice should fail (no balance)', async () => {
// const { api, accounts } = await activateWallet({
// ...TEST_NETWORK,
// mnemonic: TEST_MNEMONIC,
// } as ActivateWalletInput)
// expect(accounts.length).toBeGreaterThan(0)
// expect(accounts[0].address).toEqual(TEST_ADDRESS)

// const sender = accounts[0]
// const tx = await transfer(api, ALICE_ADDRESS, 1)

// expect(() => tx.signAndSend(sender)).toThrow(
// 'Unreachable code should not be executed (evaluating',
// // To-Do: Confirm this is the expected error message
// )
// })
})
})
6 changes: 3 additions & 3 deletions packages/auto-consensus/__test__/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ describe('Verify info functions', () => {
await activate()
})

afterAll(async () => {
await disconnect()
})
// afterAll(async () => {
// await disconnect()
// })

test('Check timestamp return a number greater than zero', async () => {
// totalIssuance is an async function that returns a hex number as a string
Expand Down
14 changes: 12 additions & 2 deletions packages/auto-consensus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.1.0",
"main": "dist/index.js",
"scripts": {
"build": "bun build ./src/index.ts --outdir ./dist",
"test": "bun test"
"build": "tsc",
"clean": "rm -rf dist",
"format": "prettier --write \"src/**/*.ts\"",
"test": "jest"
},
"files": [
"dist",
Expand All @@ -20,5 +22,13 @@
},
"dependencies": {
"@autonomys/auto-utils": "workspace:*"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"ts-jest": "^29.1.4",
"typescript": "^5.4.5"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/auto-id/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
preset: 'ts-jest',
}
13 changes: 12 additions & 1 deletion packages/auto-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
"version": "0.1.0",
"main": "dist/index.js",
"scripts": {
"build": "tsc"
"build": "tsc",
"clean": "rm -rf dist",
"format": "prettier --write \"src/**/*.ts\"",
"test": "jest"
},
"dependencies": {
"@autonomys/auto-utils": "workspace:*",
"@types/node": "^20.12.12"
},
"files": [
"dist",
"README.md"
],
"devDependencies": {
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
}
}
4 changes: 1 addition & 3 deletions packages/auto-id/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export const helloWorld = () => {
console.log('Hello World');
};
export * from './keyManagement'
Loading

0 comments on commit 3461f13

Please sign in to comment.