|
4 | 4 | import { generateKey, LanguageCode, multisig, spendingKeyToWords } from '@ironfish/rust-nodejs'
|
5 | 5 | import fs from 'fs'
|
6 | 6 | import path from 'path'
|
7 |
| -import { Assert } from '../../../assert' |
8 | 7 | import { createTrustedDealerKeyPackages, useMinerBlockFixture } from '../../../testUtilities'
|
9 | 8 | import { createRouteTest } from '../../../testUtilities/routeTest'
|
10 | 9 | import { JsonEncoder } from '../../../wallet'
|
@@ -470,187 +469,6 @@ describe('Route wallet/importAccount', () => {
|
470 | 469 | expect.assertions(2)
|
471 | 470 | })
|
472 | 471 |
|
473 |
| - it('should not import multisig account with secret with the same identity name', async () => { |
474 |
| - const name = 'duplicateIdentityNameTest' |
475 |
| - |
476 |
| - const { |
477 |
| - dealer: trustedDealerPackages, |
478 |
| - secrets, |
479 |
| - identities, |
480 |
| - } = createTrustedDealerKeyPackages() |
481 |
| - |
482 |
| - await routeTest.node.wallet.walletDb.putMultisigIdentity( |
483 |
| - Buffer.from(identities[0], 'hex'), |
484 |
| - { |
485 |
| - secret: secrets[0].serialize(), |
486 |
| - name, |
487 |
| - }, |
488 |
| - ) |
489 |
| - |
490 |
| - const indentityCountBefore = (await routeTest.client.wallet.multisig.getIdentities()) |
491 |
| - .content.identities.length |
492 |
| - |
493 |
| - const account: AccountImport = { |
494 |
| - version: 1, |
495 |
| - name, |
496 |
| - viewKey: trustedDealerPackages.viewKey, |
497 |
| - incomingViewKey: trustedDealerPackages.incomingViewKey, |
498 |
| - outgoingViewKey: trustedDealerPackages.outgoingViewKey, |
499 |
| - publicAddress: trustedDealerPackages.publicAddress, |
500 |
| - spendingKey: null, |
501 |
| - createdAt: null, |
502 |
| - proofAuthorizingKey: trustedDealerPackages.proofAuthorizingKey, |
503 |
| - multisigKeys: { |
504 |
| - publicKeyPackage: trustedDealerPackages.publicKeyPackage, |
505 |
| - keyPackage: trustedDealerPackages.keyPackages[1].keyPackage.toString(), |
506 |
| - secret: secrets[1].serialize().toString('hex'), |
507 |
| - }, |
508 |
| - ledger: false, |
509 |
| - } |
510 |
| - |
511 |
| - try { |
512 |
| - await routeTest.client.wallet.importAccount({ |
513 |
| - account: new JsonEncoder().encode(account), |
514 |
| - name, |
515 |
| - rescan: false, |
516 |
| - }) |
517 |
| - } catch (e: unknown) { |
518 |
| - if (!(e instanceof RpcRequestError)) { |
519 |
| - throw e |
520 |
| - } |
521 |
| - |
522 |
| - /** |
523 |
| - * These assertions ensures that we cannot import multiple identities with the same name. |
524 |
| - * This is done by creating an identity, storing it and attempting to import another identity but give it the same name. |
525 |
| - */ |
526 |
| - expect(e.status).toBe(400) |
527 |
| - expect(e.code).toBe(RPC_ERROR_CODES.DUPLICATE_IDENTITY_NAME) |
528 |
| - } |
529 |
| - |
530 |
| - if (account.multisigKeys && isMultisigSignerImport(account.multisigKeys)) { |
531 |
| - account.multisigKeys.secret = secrets[0].serialize().toString('hex') |
532 |
| - } else { |
533 |
| - throw new Error('Invalid multisig keys') |
534 |
| - } |
535 |
| - |
536 |
| - const response = await routeTest.client.wallet.importAccount({ |
537 |
| - account: new JsonEncoder().encode(account), |
538 |
| - name: 'account2', |
539 |
| - rescan: false, |
540 |
| - }) |
541 |
| - |
542 |
| - expect(response.status).toBe(200) |
543 |
| - expect(response.content.name).toEqual('account2') |
544 |
| - |
545 |
| - const identitiesAfter = (await routeTest.client.wallet.multisig.getIdentities()).content |
546 |
| - .identities |
547 |
| - const newIdentity = identitiesAfter.find((identity) => identity.name === name) |
548 |
| - |
549 |
| - /** |
550 |
| - * These assertions ensure that if we try to import an identity with the same secret but different name, it will pass. |
551 |
| - * However, the identity name will remain the same as the original identity that was imported first. |
552 |
| - */ |
553 |
| - expect(identitiesAfter.length).toBe(indentityCountBefore) |
554 |
| - expect(newIdentity).toBeDefined() |
555 |
| - expect(newIdentity?.name).toBe(name) |
556 |
| - |
557 |
| - expect.assertions(7) |
558 |
| - }) |
559 |
| - |
560 |
| - it('should not import hardware multisig account with same identity name', async () => { |
561 |
| - const name = 'duplicateIdentityNameTest' |
562 |
| - |
563 |
| - const { |
564 |
| - dealer: trustedDealerPackages, |
565 |
| - secrets, |
566 |
| - identities, |
567 |
| - } = createTrustedDealerKeyPackages() |
568 |
| - |
569 |
| - const identity = identities[0] |
570 |
| - const nextIdentity = identities[1] |
571 |
| - |
572 |
| - await routeTest.node.wallet.walletDb.putMultisigIdentity(Buffer.from(identity, 'hex'), { |
573 |
| - secret: secrets[0].serialize(), |
574 |
| - name, |
575 |
| - }) |
576 |
| - |
577 |
| - const account: AccountImport = { |
578 |
| - version: 1, |
579 |
| - name, |
580 |
| - viewKey: trustedDealerPackages.viewKey, |
581 |
| - incomingViewKey: trustedDealerPackages.incomingViewKey, |
582 |
| - outgoingViewKey: trustedDealerPackages.outgoingViewKey, |
583 |
| - publicAddress: trustedDealerPackages.publicAddress, |
584 |
| - proofAuthorizingKey: trustedDealerPackages.proofAuthorizingKey, |
585 |
| - spendingKey: null, |
586 |
| - createdAt: null, |
587 |
| - multisigKeys: { |
588 |
| - publicKeyPackage: trustedDealerPackages.publicKeyPackage, |
589 |
| - identity: nextIdentity, |
590 |
| - }, |
591 |
| - ledger: false, |
592 |
| - } |
593 |
| - |
594 |
| - try { |
595 |
| - await routeTest.client.wallet.importAccount({ |
596 |
| - account: new JsonEncoder().encode(account), |
597 |
| - name, |
598 |
| - rescan: false, |
599 |
| - }) |
600 |
| - } catch (e: unknown) { |
601 |
| - if (!(e instanceof RpcRequestError)) { |
602 |
| - throw e |
603 |
| - } |
604 |
| - |
605 |
| - expect(e.status).toBe(400) |
606 |
| - expect(e.code).toBe(RPC_ERROR_CODES.DUPLICATE_IDENTITY_NAME) |
607 |
| - } |
608 |
| - |
609 |
| - expect.assertions(2) |
610 |
| - }) |
611 |
| - |
612 |
| - it('should not modify existing identity if a new one is being imported with a different name', async () => { |
613 |
| - const { dealer: trustedDealerPackages, identities } = createTrustedDealerKeyPackages() |
614 |
| - |
615 |
| - const identity = identities[0] |
616 |
| - |
617 |
| - await routeTest.node.wallet.walletDb.putMultisigIdentity(Buffer.from(identity, 'hex'), { |
618 |
| - name: 'existingIdentity', |
619 |
| - }) |
620 |
| - |
621 |
| - const account: AccountImport = { |
622 |
| - version: 1, |
623 |
| - name: 'newIdentity', |
624 |
| - viewKey: trustedDealerPackages.viewKey, |
625 |
| - incomingViewKey: trustedDealerPackages.incomingViewKey, |
626 |
| - outgoingViewKey: trustedDealerPackages.outgoingViewKey, |
627 |
| - publicAddress: trustedDealerPackages.publicAddress, |
628 |
| - proofAuthorizingKey: trustedDealerPackages.proofAuthorizingKey, |
629 |
| - spendingKey: null, |
630 |
| - createdAt: null, |
631 |
| - multisigKeys: { |
632 |
| - publicKeyPackage: trustedDealerPackages.publicKeyPackage, |
633 |
| - identity: identity, |
634 |
| - }, |
635 |
| - ledger: false, |
636 |
| - } |
637 |
| - |
638 |
| - const response = await routeTest.client.wallet.importAccount({ |
639 |
| - account: new JsonEncoder().encode(account), |
640 |
| - name: 'newIdentity', |
641 |
| - rescan: false, |
642 |
| - }) |
643 |
| - |
644 |
| - expect(response.status).toBe(200) |
645 |
| - expect(response.content.name).toEqual('newIdentity') |
646 |
| - |
647 |
| - const existingIdentity = await routeTest.wallet.walletDb.getMultisigIdentity( |
648 |
| - Buffer.from(identity, 'hex'), |
649 |
| - ) |
650 |
| - Assert.isNotUndefined(existingIdentity) |
651 |
| - expect(existingIdentity.name).toEqual('existingIdentity') |
652 |
| - }) |
653 |
| - |
654 | 472 | describe('account format', () => {
|
655 | 473 | it('should decode an account import with the requested format', async () => {
|
656 | 474 | const name = 'mnemonic-format'
|
|
0 commit comments