oznfc.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: Apache-2.0
  2. import expect from 'expect';
  3. import { loadContractAndCallConstructor } from './setup';
  4. describe('Deploy solang contract and test', function () {
  5. this.timeout(500000);
  6. it('Events', async function () {
  7. const { program, storage } = await loadContractAndCallConstructor('Events');
  8. let res = await program.methods.getName()
  9. .accounts({ dataAccount: storage.publicKey })
  10. .view();
  11. expect(res).toBe("myName");
  12. await program.methods.setName('ozan')
  13. .accounts({ dataAccount: storage.publicKey })
  14. .rpc();
  15. res = await program.methods.getName()
  16. .accounts({ dataAccount: storage.publicKey })
  17. .view();
  18. expect(res).toBe('ozan');
  19. await program.methods.setSurname('martin')
  20. .accounts({ dataAccount: storage.publicKey })
  21. .rpc();
  22. res = await program.methods.getSurname()
  23. .accounts({ dataAccount: storage.publicKey })
  24. .view();
  25. expect(res).toBe('martin');
  26. res = await program.methods.getNames()
  27. .accounts({ dataAccount: storage.publicKey })
  28. .view();
  29. expect(res.name).toBe('ozan');
  30. expect(res.surname).toBe('martin');
  31. });
  32. });