Skip to content

Commit

Permalink
util: rename fromValuesArray to fromBytesArray
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottyPoi committed Aug 27, 2024
1 parent c21feae commit 2c368ea
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/block/test/eip4895block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RLP } from '@ethereumjs/rlp'
import {
Address,
KECCAK256_RLP,
createWithdrawalFromValuesArray,
createWithdrawalFromBytesArray,
hexToBytes,
randomBytes,
zeros,
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('EIP4895 tests', () => {
// get withdrawalsArray
const gethBlockBytesArray = RLP.decode(hexToBytes(`0x${gethWithdrawals8BlockRlp}`))
const withdrawals = (gethBlockBytesArray[3] as WithdrawalBytes[]).map((wa) =>
createWithdrawalFromValuesArray(wa),
createWithdrawalFromBytesArray(wa),
)
assert.equal(withdrawals.length, 8, '8 withdrawals should have been found')
const gethWithdrawalsRoot = (gethBlockBytesArray[0] as Uint8Array[])[16] as Uint8Array
Expand Down
2 changes: 1 addition & 1 deletion packages/block/test/eip7685block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('7685 tests', () => {
})
})

describe('createWithdrawalFromValuesArray tests', () => {
describe('createWithdrawalFromBytesArray tests', () => {
it('should construct a block with empty requests root', () => {
const block = createBlockFromBytesArray(
[createBlockHeader({}, { common }).raw(), [], [], [], []],
Expand Down
4 changes: 2 additions & 2 deletions packages/block/test/header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('[Block]: Header functions', () => {
}
})

it('Initialization -> createWithdrawalFromValuesArray()', () => {
it('Initialization -> createWithdrawalFromBytesArray()', () => {
const common = new Common({ chain: Mainnet, hardfork: Hardfork.London })
const zero = new Uint8Array(0)
const headerArray = []
Expand All @@ -156,7 +156,7 @@ describe('[Block]: Header functions', () => {
)
})

it('Initialization -> createWithdrawalFromValuesArray() -> error cases', () => {
it('Initialization -> createWithdrawalFromBytesArray() -> error cases', () => {
const headerArray = Array(22).fill(new Uint8Array(0))

// mock header data (if set to zeros(0) header throws)
Expand Down
4 changes: 2 additions & 2 deletions packages/tx/test/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('[BaseTransaction]', () => {
}
})

it('createWithdrawalFromValuesArray()', () => {
it('createWithdrawalFromBytesArray()', () => {
let rlpData: any = legacyTxs[0].raw()
rlpData[0] = toBytes('0x0')
try {
Expand Down Expand Up @@ -270,7 +270,7 @@ describe('[BaseTransaction]', () => {
for (const tx of txType.txs) {
assert.ok(
txType.create.bytesArray(tx.raw() as any, { common }),
`${txType.name}: should do roundtrip raw() -> createWithdrawalFromValuesArray()`,
`${txType.name}: should do roundtrip raw() -> createWithdrawalFromBytesArray()`,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/test/legacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('[Transaction]', () => {
)
})

it('Initialization -> decode with createWithdrawalFromValuesArray()', () => {
it('Initialization -> decode with createWithdrawalFromBytesArray()', () => {
for (const tx of txFixtures.slice(0, 4)) {
const txData = tx.raw.map((rawTxData) => hexToBytes(rawTxData as PrefixedHexString))
const pt = createLegacyTxFromBytesArray(txData)
Expand Down
2 changes: 1 addition & 1 deletion packages/util/src/withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Withdrawal {
}
}

export function createWithdrawalFromValuesArray(withdrawalArray: WithdrawalBytes) {
export function createWithdrawalFromBytesArray(withdrawalArray: WithdrawalBytes) {
if (withdrawalArray.length !== 4) {
throw Error(`Invalid withdrawalArray length expected=4 actual=${withdrawalArray.length}`)
}

Check warning on line 78 in packages/util/src/withdrawal.ts

View check run for this annotation

Codecov / codecov/patch

packages/util/src/withdrawal.ts#L77-L78

Added lines #L77 - L78 were not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions packages/util/test/withdrawal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
bigIntToHex,
bytesToHex,
createWithdrawal,
createWithdrawalFromValuesArray,
createWithdrawalFromBytesArray,
hexToBytes,
intToHex,
withdrawalToBytesArray,
Expand Down Expand Up @@ -93,9 +93,9 @@ describe('Withdrawal', () => {
assert.equal(gethWithdrawalsRlp, withdrawalsDataToRlp, 'The withdrawals to buffer should match')
})

it('createWithdrawalFromValuesArray, toJSON and toValue', () => {
it('createWithdrawalFromBytesArray, toJSON and toValue', () => {
const withdrawals = (gethWithdrawalsBuffer as WithdrawalBytes[]).map(
createWithdrawalFromValuesArray,
createWithdrawalFromBytesArray,
)
const withdrawalsJson = withdrawals.map((wt) => wt.toJSON())
assert.deepEqual(withdrawalsGethVector, withdrawalsJson, 'Withdrawals json should match')
Expand Down
6 changes: 3 additions & 3 deletions packages/vm/test/api/EIPs/eip-4895-withdrawals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
GWEI_TO_WEI,
KECCAK256_RLP,
bytesToHex,
createWithdrawalFromValuesArray,
createWithdrawalFromBytesArray,
hexToBytes,
parseGethGenesisState,
zeros,
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('EIP4895 tests', () => {

const gethBlockBufferArray = decode(hexToBytes(gethWithdrawals8BlockRlp))
const withdrawals = (gethBlockBufferArray[3] as WithdrawalBytes[]).map((wa) =>
createWithdrawalFromValuesArray(wa),
createWithdrawalFromBytesArray(wa),
)
assert.equal(withdrawals[0].amount, BigInt(0), 'withdrawal 0 should have 0 amount')
let block: Block
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('EIP4895 tests', () => {

const gethBlockBufferArray = decode(hexToBytes(gethWithdrawals8BlockRlp))
const withdrawals = (gethBlockBufferArray[3] as WithdrawalBytes[]).map((wa) =>
createWithdrawalFromValuesArray(wa),
createWithdrawalFromBytesArray(wa),
)
const td = await blockchain.getTotalDifficulty(genesisBlock.hash())

Expand Down

0 comments on commit 2c368ea

Please sign in to comment.