import { TezosToolkit } from '@taquito/taquito'; import { char2Bytes } from '@taquito/utils'; import { tas } from '../types-file/type-aliases'; import { ExampleContract0ContractType as ContractType } from '../types-file/example-contract-0.types'; import { ExampleContract0Code as ContractCode } from '../types-file/example-contract-0.code'; describe('example-contract-0', () => { const Tezos = new TezosToolkit('RPC_URL'); let contract: ContractType = undefined as unknown as ContractType; beforeAll(async () => { const newContractOrigination = await Tezos.contract.originate({ code: ContractCode.code, storage: tas.int('42'), }); const newContractResult = await newContractOrigination.contract(); const newContractAddress = newContractResult.address; contract = await Tezos.contract.at(newContractAddress); }); it('should call decrement', async () => { const getStorageValue = async () => { const storage = await contract.storage(); const value = storage; return value; }; const storageValueBefore = await getStorageValue(); const decrementRequest = await contract.methodsObject.decrement(tas.int('42')).send(); await decrementRequest.confirmation(3); const storageValueAfter = await getStorageValue(); expect(storageValueAfter).toBe(''); }); it('should call increment', async () => { const getStorageValue = async () => { const storage = await contract.storage(); const value = storage; return value; }; const storageValueBefore = await getStorageValue(); const incrementRequest = await contract.methodsObject.increment(tas.int('42')).send(); await incrementRequest.confirmation(3); const storageValueAfter = await getStorageValue(); expect(storageValueAfter).toBe(''); }); it('should call reset', async () => { const getStorageValue = async () => { const storage = await contract.storage(); const value = storage; return value; }; const storageValueBefore = await getStorageValue(); const resetRequest = await contract.methodsObject.reset().send(); await resetRequest.confirmation(3); const storageValueAfter = await getStorageValue(); expect(storageValueAfter).toBe(''); }); });