diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-18 21:01:18 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-18 21:01:18 +0800 |
commit | 4948551703fb3cb9f8470d9f4a61a9a5473e5afa (patch) | |
tree | 2e7d4d2e9c98cb6bebf7bdd17444d4b351220018 /packages/sol-cov/test/instructions_test.ts | |
parent | d7bf003d511321ec6cb8814cb1549c46b4efba86 (diff) | |
parent | d4c1b3b0bd26e730ce6687469cdf7283877543e1 (diff) | |
download | dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.tar dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.tar.gz dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.tar.bz2 dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.tar.lz dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.tar.xz dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.tar.zst dexon-sol-tools-4948551703fb3cb9f8470d9f4a61a9a5473e5afa.zip |
merge development
Diffstat (limited to 'packages/sol-cov/test/instructions_test.ts')
-rw-r--r-- | packages/sol-cov/test/instructions_test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/sol-cov/test/instructions_test.ts b/packages/sol-cov/test/instructions_test.ts new file mode 100644 index 000000000..195dfce2f --- /dev/null +++ b/packages/sol-cov/test/instructions_test.ts @@ -0,0 +1,20 @@ +import * as chai from 'chai'; +import * as fs from 'fs'; +import 'mocha'; +import * as path from 'path'; + +import { constants } from '../src/constants'; +import { getPcToInstructionIndexMapping } from '../src/instructions'; + +const expect = chai.expect; + +describe('instructions', () => { + describe('#getPcToInstructionIndexMapping', () => { + it('correctly maps pcs to instruction indexed', () => { + const bytecode = new Uint8Array([constants.PUSH1, 42, constants.PUSH2, 1, 2, constants.TIMESTAMP]); + const pcToInstruction = getPcToInstructionIndexMapping(bytecode); + const expectedPcToInstruction = { '0': 0, '2': 1, '5': 2 }; + expect(pcToInstruction).to.be.deep.equal(expectedPcToInstruction); + }); + }); +}); |