From 8379abf5df539ac0300be128dbbecb7573e210ad Mon Sep 17 00:00:00 2001 From: Hugh Cunningham Date: Fri, 13 Sep 2024 07:40:16 -0700 Subject: [PATCH] test memory allocation issues in rust --- .github/workflows/ci.yml | 76 +++++++-------- ironfish-rust/Cargo.toml | 2 +- .../multisig/createSigningPackage.test.ts | 92 +++++++++---------- .../src/wallet/exporter/encryption.test.ts | 6 +- 4 files changed, 89 insertions(+), 87 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c844928378..47f71db17c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: push: branches: - master + - test/hughy/ironfish-frost jobs: lint: @@ -63,7 +64,7 @@ jobs: run: yarn --non-interactive --frozen-lockfile - name: Run tests - run: yarn test:coverage --maxWorkers=2 --workerIdleMemoryLimit=2000MB + run: yarn test:coverage createSigningPackage.test.ts --maxWorkers=2 --workerIdleMemoryLimit=2000MB - name: Check for missing fixtures run: | @@ -76,39 +77,40 @@ jobs: if: github.repository == 'iron-fish/ironfish' run: CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} ROOT_PATH=$GITHUB_WORKSPACE/ yarn coverage:upload - testslow: - name: Slow Tests - runs-on: ubuntu-latest - - steps: - - name: Check out Git repository - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - # Tests will only run on Node v20 due to https://github.com/nodejs/node/issues/35889 - node-version: 20 - cache: 'yarn' - - - name: Cache Rust - uses: Swatinem/rust-cache@v2 - with: - shared-key: nodejs - - - name: Install packages - run: yarn --non-interactive --frozen-lockfile - - - name: Run slow tests & coverage - run: yarn test:slow:coverage --maxWorkers=2 --workerIdleMemoryLimit=2000MB - - - name: Check for missing fixtures - run: | - if [[ $(git status | grep fixture) ]]; then - echo "New test fixtures have not been checked in, please check them in." - exit 1 - fi - - - name: Upload coverage - if: github.repository == 'iron-fish/ironfish' - run: CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} ROOT_PATH=$GITHUB_WORKSPACE/ yarn coverage:upload + # testslow: + # name: Slow Tests + # runs-on: ubuntu-latest + # + # steps: + # - name: Check out Git repository + # uses: actions/checkout@v4 + # + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # # Tests will only run on Node v20 due to https://github.com/nodejs/node/issues/35889 + # node-version: 20 + # cache: 'yarn' + # + # - name: Cache Rust + # uses: Swatinem/rust-cache@v2 + # with: + # shared-key: nodejs + # + # - name: Install packages + # run: yarn --non-interactive --frozen-lockfile + # + # - name: Run slow tests & coverage + # run: yarn test:slow:coverage --maxWorkers=2 --workerIdleMemoryLimit=2000MB + # + # - name: Check for missing fixtures + # run: | + # if [[ $(git status | grep fixture) ]]; then + # echo "New test fixtures have not been checked in, please check them in." + # exit 1 + # fi + # + # - name: Upload coverage + # if: github.repository == 'iron-fish/ironfish' + # run: CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} ROOT_PATH=$GITHUB_WORKSPACE/ yarn coverage:upload + # \ No newline at end of file diff --git a/ironfish-rust/Cargo.toml b/ironfish-rust/Cargo.toml index 9193e10489..873007e68e 100644 --- a/ironfish-rust/Cargo.toml +++ b/ironfish-rust/Cargo.toml @@ -43,7 +43,7 @@ chacha20poly1305 = "0.10.1" crypto_box = { version = "0.9", features = ["std"] } ff = "0.12.0" group = "0.12.0" -ironfish-frost = { git = "https://github.com/iron-fish/ironfish-frost.git", branch = "main", features = ["std", "signing"] } +ironfish-frost = { git = "https://github.com/iron-fish/ironfish-frost.git", branch = "main", features = ["dkg", "std", "signing"] } fish_hash = "0.3.0" ironfish_zkp = { version = "0.2.0", path = "../ironfish-zkp" } jubjub = { git = "https://github.com/iron-fish/jubjub.git", branch = "blstrs", features = ["multiply-many"] } diff --git a/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts b/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts index 6061aa2d66..8992d5cf9c 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts @@ -7,7 +7,7 @@ import { createRouteTest } from '../../../../testUtilities/routeTest' describe('Route multisig/createSigningPackage', () => { const routeTest = createRouteTest() - it('should create signing package', async () => { + it.only('should create signing package', async () => { // Create a bunch of multisig identities const accountNames = Array.from({ length: 3 }, (_, index) => `test-account-${index}`) const participants = await Promise.all( @@ -18,53 +18,53 @@ describe('Route multisig/createSigningPackage', () => { }), ) - // Initialize the group though TDK and import the accounts generated - const trustedDealerPackage = ( - await routeTest.client.wallet.multisig.createTrustedDealerKeyPackage({ - minSigners: 2, - participants, - }) - ).content - for (const { name, identity } of participants) { - const importAccount = trustedDealerPackage.participantAccounts.find( - (account) => account.identity === identity, - ) - expect(importAccount).not.toBeUndefined() - await routeTest.client.wallet.importAccount({ - name, - account: importAccount!.account, - }) - } + // // Initialize the group though TDK and import the accounts generated + // const trustedDealerPackage = ( + // await routeTest.client.wallet.multisig.createTrustedDealerKeyPackage({ + // minSigners: 2, + // participants, + // }) + // ).content + // for (const { name, identity } of participants) { + // const importAccount = trustedDealerPackage.participantAccounts.find( + // (account) => account.identity === identity, + // ) + // expect(importAccount).not.toBeUndefined() + // await routeTest.client.wallet.importAccount({ + // name, + // account: importAccount!.account, + // }) + // } // Create an unsigned transaction - const txAccount = await useAccountAndAddFundsFixture(routeTest.wallet, routeTest.chain) - const unsignedTransaction = ( - await useUnsignedTxFixture(routeTest.wallet, txAccount, txAccount) - ) - .serialize() - .toString('hex') - - // Create signing commitments for all participants - const commitments = await Promise.all( - accountNames.map(async (accountName) => { - const signingCommitment = - await routeTest.client.wallet.multisig.createSigningCommitment({ - account: accountName, - unsignedTransaction, - signers: participants, - }) - return signingCommitment.content.commitment - }), - ) - - // Create the signing package - const responseSigningPackage = await routeTest.client.wallet.multisig.createSigningPackage({ - commitments, - unsignedTransaction, - }) - expect(responseSigningPackage.content).toMatchObject({ - signingPackage: expect.any(String), - }) + // const txAccount = await useAccountAndAddFundsFixture(routeTest.wallet, routeTest.chain) + // const unsignedTransaction = ( + // await useUnsignedTxFixture(routeTest.wallet, txAccount, txAccount) + // ) + // .serialize() + // .toString('hex') + + // // Create signing commitments for all participants + // const commitments = await Promise.all( + // accountNames.map(async (accountName) => { + // const signingCommitment = + // await routeTest.client.wallet.multisig.createSigningCommitment({ + // account: accountName, + // unsignedTransaction, + // signers: participants, + // }) + // return signingCommitment.content.commitment + // }), + // ) + + // // Create the signing package + // const responseSigningPackage = await routeTest.client.wallet.multisig.createSigningPackage({ + // commitments, + // unsignedTransaction, + // }) + // expect(responseSigningPackage.content).toMatchObject({ + // signingPackage: expect.any(String), + // }) }) it('should create signing package with a subset of signers', async () => { diff --git a/ironfish/src/wallet/exporter/encryption.test.ts b/ironfish/src/wallet/exporter/encryption.test.ts index 69be117b51..aa9e06b1e3 100644 --- a/ironfish/src/wallet/exporter/encryption.test.ts +++ b/ironfish/src/wallet/exporter/encryption.test.ts @@ -32,7 +32,7 @@ describe('Wallet Export Encryption', () => { const secret = multisig.ParticipantSecret.random() const identity = secret.toIdentity() - it('encodes an account and decodes the string', () => { + it.skip('encodes an account and decodes the string', () => { const encoded = new JsonEncoder().encode(account) const encrypted = encryptEncodedAccount(encoded, { kind: 'MultisigIdentity', @@ -43,7 +43,7 @@ describe('Wallet Export Encryption', () => { expect(decrypted).toEqual(encoded) }) - it('returns null when decoding with the wrong secret', () => { + it.skip('returns null when decoding with the wrong secret', () => { const wrongSecret = multisig.ParticipantSecret.random() const encoded = new JsonEncoder().encode(account) @@ -81,7 +81,7 @@ describe('Wallet Export Encryption', () => { expect(encrypted.slice(BASE64_JSON_MULTISIG_ENCRYPTED_ACCOUNT_PREFIX.length)).toBeBase64() }) - it('should decrypt an account using wallet secrets', async () => { + it.skip('should decrypt an account using wallet secrets', async () => { const identity = await nodeTest.wallet.createMultisigSecret('foo') const encoded = new JsonEncoder().encode(account)