Skip to content

Commit

Permalink
test memory allocation issues in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
hughy committed Sep 13, 2024
1 parent 9abbc9a commit 8379abf
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 87 deletions.
76 changes: 39 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
branches:
- master
- test/hughy/ironfish-frost

jobs:
lint:
Expand Down Expand Up @@ -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: |
Expand All @@ -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
#
2 changes: 1 addition & 1 deletion ironfish-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand 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 () => {
Expand Down
6 changes: 3 additions & 3 deletions ironfish/src/wallet/exporter/encryption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8379abf

Please sign in to comment.