Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. const chai = require('chai');
  2. const waffle = require('ethereum-waffle');
  3. const SimpleStorage = require('../build/SimpleStorage');
  4.  
  5. chai.use(waffle.solidity);
  6. const { expect } = chai;
  7.  
  8. describe('SimpleStorage test suite', async () => {
  9. const provider = waffle.createMockProvider();
  10. const [wallet] = waffle.getWallets(provider);
  11. let simpleStorageContractInstance;
  12.  
  13. before(async () => {
  14. simpleStorageContractInstance = await waffle.deployContract(
  15. wallet,
  16. SimpleStorage,
  17. [1000]
  18. );
  19. });
  20.  
  21. describe('Check constructor executed successfully', () => {
  22. it('should check data = 1000', async () => {
  23. expect(await simpleStorageContractInstance.data.call()).to.eq(1000);
  24. });
  25. });
  26.  
  27. describe('updateData', () => {
  28. context('reverts when value is 0', () => {
  29. it('should revert', async () => {
  30. await expect(simpleStorageContractInstance.updateData(0)).to.be
  31. .reverted;
  32. });
  33. });
  34.  
  35. context('Updates data successfully', () => {
  36. it('updates data from 1000 to 2000', async () => {
  37. await expect(simpleStorageContractInstance.updateData(2000))
  38. .to.emit(simpleStorageContractInstance, 'UpdateData')
  39. .withArgs(1000, 2000, Math.floor(Date.now() / 10 ** 3));
  40. });
  41.  
  42. it('check data = 2000', async () => {
  43. expect(await simpleStorageContractInstance.data.call()).to.be.eq(2000);
  44. });
  45. });
  46. });
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement