From b77f3e9aceda5bfa3368e3a52c3af6641d2da1c3 Mon Sep 17 00:00:00 2001 From: derekpierre Date: Mon, 19 Aug 2024 16:19:03 -0400 Subject: [PATCH] Update tests to obtain signer from fakeProvider() instead of using fakeSigner() utility. --- packages/pre/test/acceptance/alice-grants.test.ts | 6 +++--- packages/pre/test/acceptance/delay-enact.test.ts | 3 +-- packages/taco/test/conditions/context.test.ts | 14 +++++--------- packages/taco/test/taco.test.ts | 5 ++--- packages/taco/test/test-utils.ts | 5 +++-- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/pre/test/acceptance/alice-grants.test.ts b/packages/pre/test/acceptance/alice-grants.test.ts index fdf88cbcd..1e1442734 100644 --- a/packages/pre/test/acceptance/alice-grants.test.ts +++ b/packages/pre/test/acceptance/alice-grants.test.ts @@ -10,7 +10,6 @@ import { bytesEqual, fakePorterUri, fakeProvider, - fakeSigner, fakeUrsulas, fromBytes, mockGetUrsulas, @@ -70,9 +69,10 @@ describe('story: alice shares message with bob through policy', () => { startDate, endDate, }; + const provider = fakeProvider(); policy = await alice.grant( - fakeProvider(), - fakeSigner(), + provider, + provider.getSigner(), domains.DEVNET, fakePorterUri, policyParams, diff --git a/packages/pre/test/acceptance/delay-enact.test.ts b/packages/pre/test/acceptance/delay-enact.test.ts index 01cab8949..b88e64343 100644 --- a/packages/pre/test/acceptance/delay-enact.test.ts +++ b/packages/pre/test/acceptance/delay-enact.test.ts @@ -2,7 +2,6 @@ import { bytesEqual, fakePorterUri, fakeProvider, - fakeSigner, fakeUrsulas, mockGetUrsulas, } from '@nucypher/test-utils'; @@ -61,7 +60,7 @@ describe('story: alice creates a policy but someone else enacts it', () => { const enacted = await preEnactedPolicy.enact( provider, - fakeSigner(), + provider.getSigner(), domains.DEVNET, ); expect(enacted.txHash).toBeDefined(); diff --git a/packages/taco/test/conditions/context.test.ts b/packages/taco/test/conditions/context.test.ts index d18758554..e893766a1 100644 --- a/packages/taco/test/conditions/context.test.ts +++ b/packages/taco/test/conditions/context.test.ts @@ -7,11 +7,7 @@ import { USER_ADDRESS_PARAM_DEFAULT, USER_ADDRESS_PARAM_EXTERNAL_EIP4361, } from '@nucypher/taco-auth'; -import { - fakeAuthProviders, - fakeProvider, - fakeSigner, -} from '@nucypher/test-utils'; +import { fakeAuthProviders, fakeProvider } from '@nucypher/test-utils'; import { ethers } from 'ethers'; import { beforeAll, describe, expect, it, vi } from 'vitest'; @@ -308,8 +304,8 @@ describe('context', () => { // TODO: Move to a separate file describe('No authentication provider', () => { - let provider: ethers.providers.Provider; - let signer: ethers.Signer; + let provider: ethers.providers.Web3Provider; + let signer: ethers.providers.JsonRpcSigner; let authProviders: Record; async function testEIP4361AuthSignature( @@ -337,8 +333,8 @@ describe('No authentication provider', () => { beforeAll(async () => { await initialize(); provider = fakeProvider(); - signer = fakeSigner(); - authProviders = await fakeAuthProviders(); + signer = provider.getSigner(); + authProviders = await fakeAuthProviders(signer); }); it('throws an error if there is no auth provider', () => { diff --git a/packages/taco/test/taco.test.ts b/packages/taco/test/taco.test.ts index 589d7a9fa..5f8b59f3d 100644 --- a/packages/taco/test/taco.test.ts +++ b/packages/taco/test/taco.test.ts @@ -10,7 +10,6 @@ import { fakeDkgFlow, fakePorterUri, fakeProvider, - fakeSigner, fakeTDecFlow, mockGetRitualIdFromPublicKey, mockTacoDecrypt, @@ -48,7 +47,7 @@ describe('taco', () => { const mockedDkg = fakeDkgFlow(FerveoVariant.precomputed, 0, 4, 4); const mockedDkgRitual = fakeDkgRitual(mockedDkg); const provider = fakeProvider(aliceSecretKeyBytes); - const signer = fakeSigner(aliceSecretKeyBytes); + const signer = provider.getSigner(); const getFinalizedRitualSpy = mockGetActiveRitual(mockedDkgRitual); const messageKit = await taco.encrypt( @@ -110,7 +109,7 @@ describe('taco', () => { const mockedDkg = fakeDkgFlow(FerveoVariant.precomputed, 0, 4, 4); const mockedDkgRitual = fakeDkgRitual(mockedDkg); const provider = fakeProvider(aliceSecretKeyBytes); - const signer = fakeSigner(aliceSecretKeyBytes); + const signer = provider.getSigner(); const getFinalizedRitualSpy = mockGetActiveRitual(mockedDkgRitual); const customParamKey = ':nftId'; diff --git a/packages/taco/test/test-utils.ts b/packages/taco/test/test-utils.ts index 02de484f3..360585b1b 100644 --- a/packages/taco/test/test-utils.ts +++ b/packages/taco/test/test-utils.ts @@ -27,7 +27,7 @@ import { } from '@nucypher/shared'; import { fakeDkgFlow, - fakeSigner, + fakeProvider, fakeTDecFlow, TEST_CHAIN_ID, TEST_CONTRACT_ADDR, @@ -84,11 +84,12 @@ export const fakeDkgTDecFlowE2E: ( ) => { const ritual = fakeDkgFlow(variant, ritualId, sharesNum, threshold); const dkgPublicKey = ritual.dkg.publicKey(); + const provider = fakeProvider(); const thresholdMessageKit = await encryptMessage( message, dkgPublicKey, conditionExpr, - fakeSigner(), + provider.getSigner(), ); const { decryptionShares } = fakeTDecFlow({