Skip to content

Commit

Permalink
monorepo: fix tsc errors (#2864)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau authored Jul 6, 2023
1 parent 79761c1 commit 11f48f3
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 29 deletions.
8 changes: 6 additions & 2 deletions packages/block/test/header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,13 @@ describe('[Block]: Header functions', () => {
const bcBlockGasLimitTestData = testData.tests.BlockGasLimit2p63m1

for (const key of Object.keys(bcBlockGasLimitTestData)) {
const genesisRlp = toBytes(bcBlockGasLimitTestData[key].genesisRLP)
const genesisRlp = toBytes(
bcBlockGasLimitTestData[key as keyof typeof bcBlockGasLimitTestData].genesisRLP
)
const parentBlock = Block.fromRLPSerializedBlock(genesisRlp, { common })
const blockRlp = toBytes(bcBlockGasLimitTestData[key].blocks[0].rlp)
const blockRlp = toBytes(
bcBlockGasLimitTestData[key as keyof typeof bcBlockGasLimitTestData].blocks[0].rlp
)
const block = Block.fromRLPSerializedBlock(blockRlp, { common })
assert.doesNotThrow(() => block.validateGasLimit(parentBlock))
}
Expand Down
8 changes: 4 additions & 4 deletions packages/common/test/hardforks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,20 @@ describe('[Common]: Hardfork logic', () => {
let c = new Common({ chain: Chain.Mainnet })
const mainnetGenesisHash = chains[0][1]
let msg = 'should calc correctly for chainstart (only genesis)'
assert.equal(c._calcForkHash(Hardfork.Chainstart, mainnetGenesisHash), '0xfc64ec04', msg)
assert.equal(c['_calcForkHash'](Hardfork.Chainstart, mainnetGenesisHash), '0xfc64ec04', msg)

msg = 'should calc correctly for first applied HF'
assert.equal(c._calcForkHash(Hardfork.Homestead, mainnetGenesisHash), '0x97c2c34c', msg)
assert.equal(c['_calcForkHash'](Hardfork.Homestead, mainnetGenesisHash), '0x97c2c34c', msg)

msg = 'should calc correctly for in-between applied HF'
assert.equal(c._calcForkHash(Hardfork.Byzantium, mainnetGenesisHash), '0xa00bc324', msg)
assert.equal(c['_calcForkHash'](Hardfork.Byzantium, mainnetGenesisHash), '0xa00bc324', msg)

for (const [chain, genesisHash] of chains) {
c = new Common({ chain })
for (const hf of c.hardforks()) {
if (typeof hf.forkHash === 'string') {
const msg = `Verify forkHash calculation for: ${Chain[chain]} -> ${hf.name}`
assert.equal(c._calcForkHash(hf.name, genesisHash), hf.forkHash, msg)
assert.equal(c['_calcForkHash'](hf.name, genesisHash), hf.forkHash, msg)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/timestamp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('[Common]: Timestamp Hardfork logic', () => {
for (const hf of c.hardforks()) {
if (typeof hf.forkHash === 'string') {
const msg = `Verify forkHash calculation for: ${hf.name}`
assert.equal(c._calcForkHash(hf.name, mainnetGenesisHash), hf.forkHash, msg)
assert.equal(c['_calcForkHash'](hf.name, mainnetGenesisHash), hf.forkHash, msg)
}
}

Expand Down
7 changes: 3 additions & 4 deletions packages/evm/test/precompiles/0a-pointevaluation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ describe('Precompiles: point evaluation', () => {
}

res = await pointEvaluation(optsWithInvalidCommitment)
assert.equal(
res.exceptionError?.error,
'kzg commitment does not match versioned hash',
'precompile throws when commitment doesnt match versioned hash'
assert.ok(
res.exceptionError?.error.match('kzg commitment does not match versioned hash'),
'precompile throws when commitment does not match versioned hash'
)
}
})
Expand Down
5 changes: 2 additions & 3 deletions packages/evm/test/runCall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,8 @@ describe('RunCall tests', () => {
}

const res2 = await evm.runCall({ ...runCallArgs, skipBalance: false })
assert.equal(
res2.execResult.exceptionError?.error,
'insufficient balance',
assert.ok(
res2.execResult.exceptionError?.error.match('insufficient balance'),
'runCall reverts when insufficient sender balance and skipBalance is false'
)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/statemanager/test/proofStateManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('ProofStateManager', () => {
}
storageTrie.root(hexToBytes(storageRoot))
const addressHex = bytesToUnprefixedHex(address.bytes)
stateManager._storageTries[addressHex] = storageTrie
stateManager['_storageTries'][addressHex] = storageTrie
trie.root(stateRoot!)

const proof = await stateManager.getProof(address, storageKeys)
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('ProofStateManager', () => {
}
storageTrie.root(hexToBytes(storageRoot))
const addressHex = bytesToHex(address.bytes)
stateManager._storageTries[addressHex] = storageTrie
stateManager['_storageTries'][addressHex] = storageTrie
trie.root(stateRoot!)

// tamper with account data
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('ProofStateManager', () => {
const storageTrie = new Trie({ useKeyHashing: true })
storageTrie.root(hexToBytes(storageRoot))
const addressHex = bytesToHex(address.bytes)
stateManager._storageTries[addressHex] = storageTrie
stateManager['_storageTries'][addressHex] = storageTrie
trie.root(stateRoot!)

// tamper with account data
Expand Down
6 changes: 3 additions & 3 deletions packages/statemanager/test/stateManager.account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('StateManager -> General/Account', () => {
for (const accountCacheOpts of [{ deactivate: false }, { deactivate: true }]) {
it(`should set the state root to empty`, async () => {
const stateManager = new DefaultStateManager({ accountCacheOpts })
assert.ok(equalsBytes(stateManager._trie.root(), KECCAK256_RLP), 'it has default root')
assert.ok(equalsBytes(stateManager['_trie'].root(), KECCAK256_RLP), 'it has default root')

// commit some data to the trie
const address = new Address(hexToBytes('0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b'))
Expand All @@ -20,7 +20,7 @@ describe('StateManager -> General/Account', () => {
await stateManager.putAccount(address, account)
await stateManager.commit()
await stateManager.flush()
assert.ok(!equalsBytes(stateManager._trie.root(), KECCAK256_RLP), 'it has a new root')
assert.ok(!equalsBytes(stateManager['_trie'].root(), KECCAK256_RLP), 'it has a new root')

// set state root to empty trie root
await stateManager.setStateRoot(KECCAK256_RLP)
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('StateManager -> General/Account', () => {
assert.equal(res1!.balance, BigInt(0xfff384))

await stateManager.flush()
stateManager._accountCache?.clear()
stateManager['_accountCache']?.clear()

const res2 = await stateManager.getAccount(address)

Expand Down
2 changes: 1 addition & 1 deletion packages/statemanager/test/statemanager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('StateManager -> General', () => {
it(`should instantiate`, async () => {
const sm = new DefaultStateManager()

assert.deepEqual(sm._trie.root(), KECCAK256_RLP, 'it has default root')
assert.deepEqual(sm['_trie'].root(), KECCAK256_RLP, 'it has default root')
const res = await sm.getStateRoot()
assert.deepEqual(res, KECCAK256_RLP, 'it has default root')
})
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/test/eip4844.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ describe('Network wrapper deserialization test', () => {
})

const jsonData = deserializedTx.toJSON()
assert.deepEqual(txData, jsonData, 'toJSON should give correct json')
assert.deepEqual(txData, jsonData as any, 'toJSON should give correct json')

assert.equal(deserializedTx.blobs?.length, 1, 'contains the correct number of blobs')
assert.ok(equalsBytes(deserializedTx.blobs![0], blobs[0]), 'blobs should match')
Expand Down
6 changes: 5 additions & 1 deletion packages/tx/test/transactionFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ describe('[TransactionFactory]: Basic functions', () => {
`round-trip serialization should match (${txType.name})`
)
} else {
assert.deepEqual(tx.raw(), rawTx, `round-trip raw() creation should match (${txType.name})`)
assert.deepEqual(
tx.raw(),
rawTx as Uint8Array[],
`round-trip raw() creation should match (${txType.name})`
)
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions packages/vm/test/api/EIPs/eip-2930-accesslists.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ describe('EIP-2930 Optional Access Lists tests', () => {
await vm.runTx({ tx: txnWithAccessList })
assert.ok(trace[1][0] === 'SLOAD')
let gasUsed = trace[1][1] - trace[2][1]
assert.equal(gasUsed, BigInt(100), 'charge warm sload gas')
assert.equal(gasUsed, 100, 'charge warm sload gas')

trace = []
await vm.runTx({ tx: txnWithoutAccessList, skipNonce: true })
assert.ok(trace[1][0] === 'SLOAD')
gasUsed = trace[1][1] - trace[2][1]
assert.equal(gasUsed, BigInt(2100), 'charge cold sload gas')
assert.equal(gasUsed, 2100, 'charge cold sload gas')
})
})
6 changes: 3 additions & 3 deletions packages/vm/test/api/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('VM -> basic instantiation / boolean switches', () => {
const vm = await VM.create()
assert.ok(vm.stateManager)
assert.deepEqual(
(vm.stateManager as DefaultStateManager)._trie.root(),
(vm.stateManager as DefaultStateManager)['_trie'].root(),
KECCAK256_RLP,
'it has default trie'
)
Expand All @@ -46,7 +46,7 @@ describe('VM -> basic instantiation / boolean switches', () => {
it('should be able to activate precompiles', async () => {
const vm = await VM.create({ activatePrecompiles: true })
assert.notDeepEqual(
(vm.stateManager as DefaultStateManager)._trie.root(),
(vm.stateManager as DefaultStateManager)['_trie'].root(),
KECCAK256_RLP,
'it has different root'
)
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('VM -> setHardfork, state (deprecated), blockchain', () => {
it('should instantiate', async () => {
const vm = await setupVM()
assert.deepEqual(
(vm.stateManager as DefaultStateManager)._trie.root(),
(vm.stateManager as DefaultStateManager)['_trie'].root(),
KECCAK256_RLP,
'it has default trie'
)
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe('Wallet tests', () => {
.split('')
.map((v) => parseInt(v, 10))
const obj: any = {}
zip(selectors, keys).forEach(([sel, k]: [number, string]) => {
;(zip(selectors, keys) as [number, string][]).forEach(([sel, k]: [number, string]) => {
if ((objs as any)[sel].hasOwnProperty(k) === true) {
obj[k] = (objs as any)[sel][k]
}
Expand Down

0 comments on commit 11f48f3

Please sign in to comment.