Skip to content

Commit

Permalink
block/vm: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Apr 25, 2021
1 parent f876956 commit 52cf035
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/block/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class BlockHeader {
/**
* Alias for Header.fromHeaderData() with initWithGenesisHeader set to true.
*/
public static genesis(headerData: HeaderData = {}, opts: BlockOptions) {
public static genesis(headerData: HeaderData = {}, opts?: BlockOptions) {
opts = { ...opts, initWithGenesisHeader: true }
return BlockHeader.fromHeaderData(headerData, opts)
}
Expand Down
7 changes: 7 additions & 0 deletions packages/vm/lib/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
PreByzantiumTxReceipt,
PostByzantiumTxReceipt,
EIP2930Receipt,
EIP1559Receipt,
} from './types'

/**
Expand Down Expand Up @@ -431,6 +432,12 @@ export async function generateTxReceipt(
status: txResult.execResult.exceptionError ? 0 : 1,
...baseReceipt,
} as EIP2930Receipt
} else if ('transactionType' in tx && tx.transactionType === 2) {
// EIP2930 Transaction
receipt = {
status: txResult.execResult.exceptionError ? 0 : 1,
...baseReceipt,
} as EIP1559Receipt
} else {
throw new Error(
`Unsupported transaction type ${'transactionType' in tx ? tx.transactionType : 'NaN'}`
Expand Down
4 changes: 3 additions & 1 deletion packages/vm/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ export interface PostByzantiumTxReceipt extends BaseTxReceipt {
status: 0 | 1
}

// EIP290Receipt, which has the same fields as PostByzantiumTxReceipt
// EIP2930Receipt, which has the same fields as PostByzantiumTxReceipt
export interface EIP2930Receipt extends PostByzantiumTxReceipt {}
// EIP1559Receipt, which has the same fields as PostByzantiumTxReceipt
export interface EIP1559Receipt extends PostByzantiumTxReceipt {}
2 changes: 1 addition & 1 deletion packages/vm/tests/api/runTx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ tape('runTx() -> API return values', async (t) => {
)
t.deepEqual(
res.amountSpent,
res.gasUsed.mul(tx.gasPrice),
res.gasUsed.mul((<Transaction>tx).gasPrice), // can cast this, since Fee Market transactions are not included
`runTx result -> amountSpent -> gasUsed * gasPrice (${txType.name})`
)
t.deepEqual(
Expand Down

0 comments on commit 52cf035

Please sign in to comment.