basic-4.js 645 B

12345678910111213141516171819202122232425
  1. const assert = require('assert');
  2. const anchor = require('@project-serum/anchor');
  3. describe('basic-4', () => {
  4. // Configure the client to use the local cluster.
  5. anchor.setProvider(anchor.Provider.local());
  6. it('Is initialized!', async () => {
  7. const program = anchor.workspace.Basic4;
  8. // #region code
  9. // The data to set on the state struct.
  10. const data = new anchor.BN(1234);
  11. // Initialize the program's state struct.
  12. await program.state.rpc.new(data);
  13. // Fetch the state struct from the network.
  14. const state = await program.state();
  15. // #endregion code
  16. assert.ok(state.data.eq(data));
  17. });
  18. });