[Q] Config for metaplex testing
ohaddahan opened this issue · comments
Trying to run some anchor
testing, using same config as https://github.com/metaplex-foundation/js-next/blob/main/.ammanrc.js (pasted my exact one, below)
But I get the failure:
Caused By: Error: failed to send transaction: Transaction simulation failed: Attempt to load a program that does not exist
When I try to run:
metaplex.nfts().create
.
Would love some guidance how to properly config to load metaplex
programs into amman
.
import { LOCALHOST, tmpLedgerDir } from '@metaplex-foundation/amman'
const path = require('path');
const mplCandyMachine = require('@metaplex-foundation/mpl-candy-machine');
const mplTokenMetadata = require('@metaplex-foundation/mpl-token-metadata');
function localDeployPath(programName) {
return path.join(__dirname, 'test', 'programs', `${programName}.so`);
}
const accountProviders = {
CandyMachine: mplCandyMachine.CandyMachine,
CollectionPDA: mplCandyMachine.CollectionPDA,
CollectionAuthorityRecord: mplTokenMetadata.CollectionAuthorityRecord,
Edition: mplTokenMetadata.Edition,
EditionMarker: mplTokenMetadata.EditionMarker,
MasterEditionV2: mplTokenMetadata.MasterEditionV2,
Metadata: mplTokenMetadata.Metadata,
ReservationListV2: mplTokenMetadata.ReservationListV2,
UseAuthorityRecord: mplTokenMetadata.UseAuthorityRecord
};
const programIds = {
metadata: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
vault: 'vau1zxA2LbssAUEF7Gpw91zMM1LvXrvpzJtmZ58rPsn',
auction: 'auctxRXPeJoc4817jDhf4HbjnhEcr1cCXenosMhK5R8',
metaplex: 'p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98',
fixedPriceSaleToken: 'SaLeTjyUa5wXHnGuewUSyJ5JWZaHwz3TxqUntCE9czo',
candyMachine: 'cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ',
};
const programs = [
{
label: 'Token Metadata',
programId: programIds.metadata,
deployPath: localDeployPath('mpl_token_metadata'),
},
{
label: 'Candy Machine',
programId: programIds.candyMachine,
deployPath: localDeployPath('mpl_candy_machine'),
},
];
module.exports = {
validator: {
killRunningValidators: true,
programs,
jsonRpcUrl: LOCALHOST,
websocketUrl: '',
commitment: 'confirmed',
ledgerDir: tmpLedgerDir(),
resetLedger: true,
verifyFees: false,
},
relay: {
accountProviders,
},
};
nvm, resolved, thanks.
Hi @ohaddahan could you elaborate on how you solved this? I'm hitting a similar issue and I'm not sure how to set up testing
For anyone still trying to figure out how to set up config to preload programs for auto-deployment on start, here is what worked for me:
const path = require('path');
function localDeployPath(programName) {
// return path.join(__dirname, 'programs', `${programName}.so`);
return path.join(__dirname, `target`, `deploy`, `${programName}.so`);
}
const programIds = {
program_to_deploy: "8dzhoiK95bw2JucMCG3GA8nFPCNk5ZUMHAY5To8kjxKh"
}
module.exports = {
validator: {
killRunningValidators: true,
programs: [
{
label: 'My Program',
programId: programIds.program_to_deploy,
deployPath: localDeployPath('program_to_deploy')
},
],
jsonRpcUrl: LOCALHOST,
websocketUrl: '',
commitment: 'confirmed',
ledgerDir: tmpLedgerDir(),
resetLedger: true,
verifyFees: false,
detached: process.env.CI != null,
},
relay: {
enabled: process.env.CI == null,
killlRunningRelay: true,
},
storage: {
enabled: process.env.CI == null,
storageId: 'mock-storage',
clearOnStart: true,
},
}```
You need to point localDeployPath to the target/deploy/program_to_deploy.so file. Hope this helps