github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/js/src/test/simple-storage.test.ts (about)

     1  import * as assert from 'assert';
     2  import { compile } from '../contracts/compile';
     3  import { client } from './test';
     4  
     5  describe('Simple storage', function () {
     6    it('sets and gets a value from a contract', async () => {
     7      const source = `
     8        pragma solidity >=0.0.0;
     9        contract SimpleStorage {
    10            uint storedData;
    11  
    12            function set(uint x) public {
    13                storedData = x;
    14            }
    15  
    16            function get() view public returns (uint retVal) {
    17                return storedData;
    18            }
    19        }
    20      `;
    21      const contract = compile(source, 'SimpleStorage');
    22      return contract
    23        .deploy(client)
    24        .then((instance: any) => instance.set(42).then(() => instance.get()))
    25        .then((value) => {
    26          assert.deepStrictEqual([...value], [42]);
    27        });
    28    });
    29  });