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

     1  import * as assert from 'assert';
     2  import { compile } from '../contracts/compile';
     3  import { client } from './test';
     4  
     5  describe('BN', function () {
     6    it('BN', async () => {
     7      const source = `
     8        pragma solidity >=0.0.0;
     9        contract Test {
    10            function mul(int a, int b) public pure returns (int) {
    11              return a * b;
    12            }
    13  
    14            function getNumber() public pure returns (uint) {
    15              return 1e19;
    16            }
    17        }
    18      `;
    19      const contract = compile(source, 'Test');
    20      const instance = await contract.deploy(client);
    21  
    22      const [number] = await instance.getNumber();
    23      assert.strictEqual(number.toString(), '10000000000000000000');
    24  
    25      const [smallNumber] = await instance.mul(100, -300);
    26      assert.strictEqual(smallNumber, -30000);
    27  
    28      const [bigNumber] = await instance.mul('18446744073709551616', 102);
    29      assert.strictEqual(bigNumber.toString(), '1881567895518374264832');
    30    });
    31  });