Skip to content

Instantly share code, notes, and snippets.

@merlox
Created February 24, 2022 23:51
Show Gist options
  • Save merlox/d434302ffe72b25b5b0f025f5ec864f9 to your computer and use it in GitHub Desktop.
Save merlox/d434302ffe72b25b5b0f025f5ec864f9 to your computer and use it in GitHub Desktop.
This is the second test for the Solana Rust program
import { expect } from 'chai' // Keep this at the beginning of the file along with the other imports
it('Should write an article with 1 word successfully', async () => {
const deployerKeypair = anchor.web3.Keypair.generate()
const personThatPays = program.provider.wallet
// Add your test here
await program.rpc.initialize({
accounts: {
article: deployerKeypair.publicKey,
personThatPays: personThatPays.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
},
signers: [deployerKeypair],
})
await program.rpc.writeIntoArticle('hey', {
accounts: {
article: deployerKeypair.publicKey,
},
signers: [],
})
const articleData = await program.account.article.fetch(deployerKeypair.publicKey)
expect(articleData.content).to.equal('hey ') // Note the space at the end, added by the program
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment