Skip to content

Commit

Permalink
Merge f49a60e into b1e0dde
Browse files Browse the repository at this point in the history
  • Loading branch information
aikchun committed Jun 21, 2021
2 parents b1e0dde + f49a60e commit 2343f19
Show file tree
Hide file tree
Showing 4 changed files with 591 additions and 20 deletions.
342 changes: 342 additions & 0 deletions packages/jellyfish-transaction/__tests__/script/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,348 @@ describe('[OP_RETURN]', () => {
})
})

describe('[OP_TOALTSTACK]', () => {
const hex = '016b'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_TOALTSTACK')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_TOALTSTACK], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_FROMALTSTACK]', () => {
const hex = '016c'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_FROMALTSTACK')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_FROMALTSTACK], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_2DROP]', () => {
const hex = '016d'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_2DROP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_2DROP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_2DUP]', () => {
const hex = '016e'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_2DUP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_2DUP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_3DUP]', () => {
const hex = '016f'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_3DUP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_3DUP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_2OVER]', () => {
const hex = '0170'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_2OVER')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_2OVER], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_2ROT]', () => {
const hex = '0171'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_2ROT')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_2ROT], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_2SWAP]', () => {
const hex = '0172'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_2SWAP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_2SWAP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_IFDUP]', () => {
const hex = '0173'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_IFDUP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_IFDUP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_DEPTH]', () => {
const hex = '0174'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_DEPTH')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_DEPTH], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_DROP]', () => {
const hex = '0175'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_DROP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_DROP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_DUP]', () => {
const hex = '0176'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_DUP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_DUP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_NIP]', () => {
const hex = '0177'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_NIP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_NIP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_OVER]', () => {
const hex = '0178'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_OVER')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_OVER], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_PICK]', () => {
const hex = '0179'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_PICK')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_PICK], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_ROLL]', () => {
const hex = '017a'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_ROLL')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_ROLL], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_ROT]', () => {
const hex = '017b'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_ROT')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_ROT], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_SWAP]', () => {
const hex = '017c'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_SWAP')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_SWAP], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_TUCK]', () => {
const hex = '017d'

it('should map fromBuffer', () => {
const codes = OP_CODES.fromBuffer(SmartBuffer.fromBuffer(
Buffer.from(hex, 'hex')
))
expect(codes[0].type).toStrictEqual('OP_TUCK')
expect(codes.length).toStrictEqual(1)
})

it('should map toBuffer', () => {
const smartBuffer = new SmartBuffer()
OP_CODES.toBuffer([OP_CODES.OP_TUCK], smartBuffer)
expect(smartBuffer.toBuffer().toString('hex')).toStrictEqual(hex)
})
})

describe('[OP_RIPEMD160]', () => {
const hex = '01a6'

Expand Down
Loading

0 comments on commit 2343f19

Please sign in to comment.