|
| 1 | +// tslint:disable:no-expression-statement no-magic-numbers |
| 2 | +import test from 'ava'; |
| 3 | + |
| 4 | +import { |
| 5 | + AuthenticationInstruction, |
| 6 | + createAuthenticationProgramExternalStateCommonEmpty, |
| 7 | + createAuthenticationProgramStateCommon |
| 8 | +} from '../../auth'; |
| 9 | +import { |
| 10 | + AuthenticationProgramStateBCH, |
| 11 | + instantiateVirtualMachineBCH, |
| 12 | + OpcodesBCH |
| 13 | +} from '../../instruction-sets/bch/bch'; |
| 14 | + |
| 15 | +import { sampledEvaluateReductionTraceNodes } from './reduce'; |
| 16 | + |
| 17 | +const vmPromise = instantiateVirtualMachineBCH(); |
| 18 | +const createCreateStateWithStack = <Opcodes, Errors>(stack: Uint8Array[]) => ( |
| 19 | + instructions: ReadonlyArray<AuthenticationInstruction<Opcodes>> |
| 20 | +) => |
| 21 | + createAuthenticationProgramStateCommon<Opcodes, Errors>( |
| 22 | + instructions, |
| 23 | + stack, |
| 24 | + createAuthenticationProgramExternalStateCommonEmpty() |
| 25 | + ); |
| 26 | +const state = createCreateStateWithStack< |
| 27 | + OpcodesBCH, |
| 28 | + AuthenticationProgramStateBCH |
| 29 | +>([])([]) as AuthenticationProgramStateBCH; |
| 30 | +const getState = () => state; |
| 31 | + |
| 32 | +test('sampledEvaluateReductionTraceNodes: empty evaluation', async t => { |
| 33 | + const vm = await vmPromise; |
| 34 | + t.deepEqual( |
| 35 | + sampledEvaluateReductionTraceNodes< |
| 36 | + OpcodesBCH, |
| 37 | + AuthenticationProgramStateBCH |
| 38 | + >( |
| 39 | + [ |
| 40 | + { |
| 41 | + bytecode: Uint8Array.of(), |
| 42 | + range: { |
| 43 | + endColumn: 1, |
| 44 | + endLineNumber: 1, |
| 45 | + startColumn: 1, |
| 46 | + startLineNumber: 1 |
| 47 | + } |
| 48 | + } |
| 49 | + ], |
| 50 | + vm, |
| 51 | + getState |
| 52 | + ), |
| 53 | + { |
| 54 | + bytecode: Uint8Array.of(), |
| 55 | + samples: [ |
| 56 | + { |
| 57 | + range: { |
| 58 | + endColumn: 1, |
| 59 | + endLineNumber: 1, |
| 60 | + startColumn: 1, |
| 61 | + startLineNumber: 1 |
| 62 | + }, |
| 63 | + state |
| 64 | + } |
| 65 | + ], |
| 66 | + success: true |
| 67 | + } |
| 68 | + ); |
| 69 | +}); |
0 commit comments