diff --git a/packages/cashscript/test/Contract.test.ts b/packages/cashscript/test/Contract.test.ts index 14e595b6..a31a16d0 100644 --- a/packages/cashscript/test/Contract.test.ts +++ b/packages/cashscript/test/Contract.test.ts @@ -11,21 +11,24 @@ import { import { alicePkh, alicePriv, alicePub, bobPriv, } from './fixture/vars.js'; -import p2pkhArtifact from './fixture/p2pkh.json' with { type: 'json' }; -import twtArtifact from './fixture/transfer_with_timeout.json' with { type: 'json' }; -import hodlVaultArtifact from './fixture/hodl_vault.json' with { type: 'json' }; -import mecenasArtifact from './fixture/mecenas.json' with { type: 'json' }; +import p2pkhArtifact from './fixture/p2pkh.artifact.js'; +import twtArtifact from './fixture/transfer_with_timeout.artifact.js'; +import hodlVaultArtifact from './fixture/hodl_vault.artifact.js'; +import mecenasArtifact from './fixture/mecenas.artifact.js'; import deprecatedMecenasArtifact from './fixture/deprecated/mecenas-v0.6.0.json' with { type: 'json' }; -import boundedBytesArtifact from './fixture/bounded_bytes.json' with { type: 'json' }; +import boundedBytesArtifact from './fixture/bounded_bytes.artifact.js'; describe('Contract', () => { describe('new', () => { it('should fail with incorrect constructor args', () => { const provider = new ElectrumNetworkProvider(Network.CHIPNET); + // @ts-expect-error invalid constructor type expect(() => new Contract(p2pkhArtifact, [], { provider })).toThrow(); + // @ts-expect-error invalid constructor type expect(() => new Contract(p2pkhArtifact, [20n], { provider })).toThrow(); expect( + // @ts-expect-error invalid constructor type () => new Contract(p2pkhArtifact, [placeholder(20), placeholder(20)], { provider }), ).toThrow(); expect(() => new Contract(p2pkhArtifact, [placeholder(19)], { provider })).toThrow(); @@ -62,8 +65,7 @@ describe('Contract', () => { it('should create new TransferWithTimeout instance', () => { const provider = new ElectrumNetworkProvider(Network.CHIPNET); - const constructorArgs = [placeholder(65), placeholder(65), 1000000n]; - const instance = new Contract(twtArtifact, constructorArgs, { provider }); + const instance = new Contract(twtArtifact, [placeholder(65), placeholder(65), 1000000n], { provider }); expect(typeof instance.address).toBe('string'); expect(typeof instance.functions.transfer).toBe('function'); @@ -73,8 +75,7 @@ describe('Contract', () => { it('should create new HodlVault instance', () => { const provider = new ElectrumNetworkProvider(Network.CHIPNET); - const constructorArgs = [placeholder(65), placeholder(65), 1000000n, 10000n]; - const instance = new Contract(hodlVaultArtifact, constructorArgs, { provider }); + const instance = new Contract(hodlVaultArtifact, [placeholder(65), placeholder(65), 1000000n, 10000n], { provider }); expect(typeof instance.address).toBe('string'); expect(typeof instance.functions.spend).toBe('function'); @@ -83,8 +84,7 @@ describe('Contract', () => { it('should create new Mecenas instance', () => { const provider = new ElectrumNetworkProvider(Network.CHIPNET); - const constructorArgs = [placeholder(20), placeholder(20), 1000000n]; - const instance = new Contract(mecenasArtifact, constructorArgs, { provider }); + const instance = new Contract(mecenasArtifact, [placeholder(20), placeholder(20), 1000000n], { provider }); expect(typeof instance.address).toBe('string'); expect(typeof instance.functions.receive).toBe('function'); diff --git a/packages/cashscript/test/TransactionBuilder.test.ts b/packages/cashscript/test/TransactionBuilder.test.ts index 59e94028..8e8738a4 100644 --- a/packages/cashscript/test/TransactionBuilder.test.ts +++ b/packages/cashscript/test/TransactionBuilder.test.ts @@ -12,8 +12,8 @@ import { } from './fixture/vars.js'; import { Network } from '../src/interfaces.js'; import { utxoComparator, calculateDust, randomUtxo, randomToken, isNonTokenUtxo, isFungibleTokenUtxo } from '../src/utils.js'; -import p2pkhArtifact from './fixture/p2pkh.json' with { type: 'json' }; -import twtArtifact from './fixture/transfer_with_timeout.json' with { type: 'json' }; +import p2pkhArtifact from './fixture/p2pkh.artifact.js'; +import twtArtifact from './fixture/transfer_with_timeout.artifact.js'; import { TransactionBuilder } from '../src/TransactionBuilder.js'; import { gatherUtxos, getTxOutputs } from './test-util.js'; @@ -22,8 +22,8 @@ describe('Transaction Builder', () => { ? new MockNetworkProvider() : new ElectrumNetworkProvider(Network.CHIPNET); - let p2pkhInstance: Contract; - let twtInstance: Contract; + let p2pkhInstance: Contract; + let twtInstance: Contract; beforeAll(() => { // Note: We instantiate the contract with carolPkh to avoid mempool conflicts with other (P2PKH) tests diff --git a/packages/cashscript/test/e2e/P2PKH-tokens.test.ts b/packages/cashscript/test/e2e/P2PKH-tokens.test.ts index dbca1fcb..933a41dd 100644 --- a/packages/cashscript/test/e2e/P2PKH-tokens.test.ts +++ b/packages/cashscript/test/e2e/P2PKH-tokens.test.ts @@ -9,10 +9,10 @@ import { } from '../fixture/vars.js'; import { getTxOutputs } from '../test-util.js'; import { Network, TokenDetails, Utxo } from '../../src/interfaces.js'; -import artifact from '../fixture/p2pkh.json' with { type: 'json' }; +import artifact from '../fixture/p2pkh.artifact.js'; describe('P2PKH-tokens', () => { - let p2pkhInstance: Contract; + let p2pkhInstance: Contract; beforeAll(() => { const provider = process.env.TESTS_USE_MOCKNET diff --git a/packages/cashscript/test/e2e/TokenCategoryCheck.test.ts b/packages/cashscript/test/e2e/TokenCategoryCheck.test.ts index 36ca67ba..ab95ba9a 100644 --- a/packages/cashscript/test/e2e/TokenCategoryCheck.test.ts +++ b/packages/cashscript/test/e2e/TokenCategoryCheck.test.ts @@ -4,7 +4,7 @@ import { TransactionBuilder, } from '../../src/index.js'; import { Network } from '../../src/interfaces.js'; -import artifact from '../fixture/token_category_comparison.json' with { type: 'json' }; +import artifact from '../fixture/token_category_comparison.artifact.js'; describe('TokenCategoryCheck', () => { const provider = process.env.TESTS_USE_MOCKNET diff --git a/packages/cashscript/test/e2e/misc/timelocks.test.ts b/packages/cashscript/test/e2e/misc/timelocks.test.ts index bb329e96..03ed406b 100644 --- a/packages/cashscript/test/e2e/misc/timelocks.test.ts +++ b/packages/cashscript/test/e2e/misc/timelocks.test.ts @@ -9,8 +9,8 @@ import { } from '../../fixture/vars.js'; import { Network } from '../../../src/interfaces.js'; import { utxoComparator, calculateDust, randomUtxo, isNonTokenUtxo } from '../../../src/utils.js'; -import p2pkhArtifact from '../../fixture/p2pkh.json' with { type: 'json' }; -import twtArtifact from '../../fixture/transfer_with_timeout.json' with { type: 'json' }; +import p2pkhArtifact from '../../fixture/p2pkh.artifact.js'; +import twtArtifact from '../../fixture/transfer_with_timeout.artifact.js'; import { TransactionBuilder } from '../../../src/TransactionBuilder.js'; import { describeOrSkip, getTxOutputs } from '../../test-util.js'; @@ -20,8 +20,8 @@ describe('Timelocks', () => { ? new MockNetworkProvider() : new ElectrumNetworkProvider(Network.CHIPNET); - let p2pkhInstance: Contract; - let twtInstance: Contract; + let p2pkhInstance: Contract; + let twtInstance: Contract; beforeAll(() => { // Note: We instantiate the contract with carolPkh to avoid mempool conflicts with other (P2PKH) tests diff --git a/packages/cashscript/test/e2e/network/FullStack.test.ts b/packages/cashscript/test/e2e/network/FullStack.test.ts index 4fb3fd7e..7f2472f0 100644 --- a/packages/cashscript/test/e2e/network/FullStack.test.ts +++ b/packages/cashscript/test/e2e/network/FullStack.test.ts @@ -8,7 +8,7 @@ import { } from '../../fixture/vars.js'; import { describeOrSkip, getTxOutputs } from '../../test-util.js'; import { FailedRequireError } from '../../../src/Errors.js'; -import artifact from '../../fixture/p2pkh.json' with { type: 'json' }; +import artifact from '../../fixture/p2pkh.artifact.js'; describeOrSkip(!process.env.TESTS_USE_MOCKNET, 'test FullStackNetworkProvider', () => { const provider = new FullStackNetworkProvider('mainnet', new BCHJS({ restURL: 'https://api.fullstack.cash/v5/' }));