import tape = require('tape')
import blockFromRpc from '../src/from-rpc'
import blockHeaderFromRpc from '../src/header-from-rpc'
import * as blockData from './testdata/testdata-from-rpc.json'
import * as blockDataWithUncles from './testdata/testdata-from-rpc-with-uncles.json'
import * as uncleBlockData from './testdata/testdata-from-rpc-with-uncles_uncle-block-data.json'

tape('[fromRPC]: block #2924874', function(t) {
  t.test('should create a block with transactions with valid signatures', function(st) {
    let block = blockFromRpc(blockData)
    let allValid = block.transactions.every(tx => tx.verifySignature())
    let block = blockHeaderFromRpc(blockData)
    st.ok(block.hash().compare(Buffer.from(blockData.hash)))
    st.end()
  })

  t.test('should create a block with uncles', function(st) {
    let block = blockFromRpc(blockDataWithUncles, [uncleBlockData])
    st.ok(block.validateUnclesHash())
    st.end()
  })
})
    st.equal(allValid, true, 'all transaction signatures are valid')
    st.end()
  })

  t.test('should create a block header with the correct hash', function(st) {