Skip to content

Commit

Permalink
Refactor eest blockchain test flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Mdaiki0730 committed Jan 28, 2025
1 parent 688ac24 commit 3adc01d
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 340 deletions.
1 change: 0 additions & 1 deletion blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,6 @@ func (bc *BlockChain) ApplyTransaction(chainConfig *params.ChainConfig, author *
}
// Create a new context to be used in the EVM environment
blockContext := NewEVMBlockContext(header, bc, author)

txContext := NewEVMTxContext(msg, header, chainConfig)
// Create a new environment which holds all relevant information
// about the transaction and calling mechanisms.
Expand Down
2 changes: 2 additions & 0 deletions blockchain/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) {
b.receipts = append(b.receipts, receipt)
}

// AddTxWithChainEvenHasError is an AddTx that inherits the vmConfig of the received chain
// and does not panic even if an error occurs.
func (b *BlockGen) AddTxWithChainEvenHasError(bc *BlockChain, tx *types.Transaction) error {
b.statedb.SetTxContext(tx.Hash(), common.Hash{}, len(b.txs))
var vmConfig vm.Config
Expand Down
10 changes: 7 additions & 3 deletions blockchain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ func (g *Genesis) ToBlock(baseStateRoot common.Hash, db database.DBManager) *typ
if len(account.Code) != 0 {
originalCode := stateDB.GetCode(addr)
rules := g.Config.Rules(new(big.Int).SetUint64(g.Number))
if _, ok := types.ParseDelegation(account.Code); ok {
stateDB.SetCodeToEOA(addr, account.Code, rules)
if rules.IsPrague {
if _, ok := types.ParseDelegation(account.Code); ok {
stateDB.SetCodeToEOA(addr, account.Code, rules)
} else {
stateDB.CreateSmartContractAccount(addr, params.CodeFormatEVM, rules)
stateDB.SetCode(addr, account.Code)
}
} else {
stateDB.CreateSmartContractAccount(addr, params.CodeFormatEVM, rules)
stateDB.SetCode(addr, account.Code)
}
// If originalCode is not nil,
Expand Down
4 changes: 0 additions & 4 deletions rlp/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,10 +1085,6 @@ func (s *Stream) readFull(buf []byte) (err error) {
return err
}

func (s *Stream) ReadByte() (byte, error) {
return s.readByte()
}

// readByte reads a single byte from the underlying stream.
func (s *Stream) readByte() (byte, error) {
if err := s.willRead(1); err != nil {
Expand Down
24 changes: 0 additions & 24 deletions tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,6 @@ import (
"github.com/stretchr/testify/suite"
)

func TestBlockchain(t *testing.T) {
t.Parallel()

bt := new(testMatcher)
// General state tests are 'exported' as blockchain tests, but we can run them natively.
bt.skipLoad(`^GeneralStateTests/`)
// Skip random failures due to selfish mining test.
// bt.skipLoad(`^bcForgedTest/bcForkUncle\.json`)
bt.skipLoad(`^bcMultiChainTest/(ChainAtoChainB_blockorder|CallContractFromNotBestBlock)`)
bt.skipLoad(`^bcTotalDifficultyTest/(lotsOfLeafs|lotsOfBranches|sideChainWithMoreTransactions)`)
// This test is broken
bt.fails(`blockhashNonConstArg_Constantinople`, "Broken test")

// Still failing tests
// bt.skipLoad(`^bcWalletTest.*_Byzantium$`)

// TODO-Kaia Update BlockchainTests first to enable this test, since block header has been changed in Kaia.
//bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
// if err := bt.checkFailure(t, name, test.Run()); err != nil {
// t.Error(err)
// }
//})
}

// TestExecutionSpecState runs the state_test fixtures from execution-spec-tests.
type ExecutionSpecBlockTestSuite struct {
suite.Suite
Expand Down
Loading

0 comments on commit 3adc01d

Please sign in to comment.