Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
60617073
Commit
60617073
authored
Nov 28, 2016
by
Jeffrey Wilcke
Committed by
Felix Lange
Nov 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: eip unit tests (#3309)
parent
4c8c5e2f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
7 deletions
+71
-7
blockchain_test.go
core/blockchain_test.go
+71
-7
No files found.
core/blockchain_test.go
View file @
60617073
...
@@ -1140,7 +1140,8 @@ func TestEIP155Transition(t *testing.T) {
...
@@ -1140,7 +1140,8 @@ func TestEIP155Transition(t *testing.T) {
key
,
_
=
crypto
.
HexToECDSA
(
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
)
key
,
_
=
crypto
.
HexToECDSA
(
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
)
address
=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
address
=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
funds
=
big
.
NewInt
(
1000000000
)
funds
=
big
.
NewInt
(
1000000000
)
genesis
=
WriteGenesisBlockForTesting
(
db
,
GenesisAccount
{
address
,
funds
})
deleteAddr
=
common
.
Address
{
1
}
genesis
=
WriteGenesisBlockForTesting
(
db
,
GenesisAccount
{
address
,
funds
},
GenesisAccount
{
deleteAddr
,
new
(
big
.
Int
)})
config
=
&
params
.
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
EIP155Block
:
big
.
NewInt
(
2
),
HomesteadBlock
:
new
(
big
.
Int
)}
config
=
&
params
.
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
EIP155Block
:
big
.
NewInt
(
2
),
HomesteadBlock
:
new
(
big
.
Int
)}
mux
event
.
TypeMux
mux
event
.
TypeMux
)
)
...
@@ -1231,3 +1232,66 @@ func TestEIP155Transition(t *testing.T) {
...
@@ -1231,3 +1232,66 @@ func TestEIP155Transition(t *testing.T) {
t
.
Error
(
"expected error:"
,
types
.
ErrInvalidChainId
)
t
.
Error
(
"expected error:"
,
types
.
ErrInvalidChainId
)
}
}
}
}
func
TestEIP161AccountRemoval
(
t
*
testing
.
T
)
{
// Configure and generate a sample block chain
var
(
db
,
_
=
ethdb
.
NewMemDatabase
()
key
,
_
=
crypto
.
HexToECDSA
(
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
)
address
=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
funds
=
big
.
NewInt
(
1000000000
)
theAddr
=
common
.
Address
{
1
}
genesis
=
WriteGenesisBlockForTesting
(
db
,
GenesisAccount
{
address
,
funds
})
config
=
&
params
.
ChainConfig
{
ChainId
:
big
.
NewInt
(
1
),
HomesteadBlock
:
new
(
big
.
Int
),
EIP155Block
:
new
(
big
.
Int
),
EIP158Block
:
big
.
NewInt
(
2
),
}
mux
event
.
TypeMux
blockchain
,
_
=
NewBlockChain
(
db
,
config
,
FakePow
{},
&
mux
)
)
blocks
,
_
:=
GenerateChain
(
config
,
genesis
,
db
,
3
,
func
(
i
int
,
block
*
BlockGen
)
{
var
(
tx
*
types
.
Transaction
err
error
signer
=
types
.
NewEIP155Signer
(
config
.
ChainId
)
)
switch
i
{
case
0
:
tx
,
err
=
types
.
NewTransaction
(
block
.
TxNonce
(
address
),
theAddr
,
new
(
big
.
Int
),
big
.
NewInt
(
21000
),
new
(
big
.
Int
),
nil
)
.
SignECDSA
(
signer
,
key
)
case
1
:
tx
,
err
=
types
.
NewTransaction
(
block
.
TxNonce
(
address
),
theAddr
,
new
(
big
.
Int
),
big
.
NewInt
(
21000
),
new
(
big
.
Int
),
nil
)
.
SignECDSA
(
signer
,
key
)
case
2
:
tx
,
err
=
types
.
NewTransaction
(
block
.
TxNonce
(
address
),
theAddr
,
new
(
big
.
Int
),
big
.
NewInt
(
21000
),
new
(
big
.
Int
),
nil
)
.
SignECDSA
(
signer
,
key
)
}
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
block
.
AddTx
(
tx
)
})
// account must exist pre eip 161
if
_
,
err
:=
blockchain
.
InsertChain
(
types
.
Blocks
{
blocks
[
0
]});
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
blockchain
.
stateCache
.
Exist
(
theAddr
)
{
t
.
Error
(
"expected account to exist"
)
}
// account needs to be deleted post eip 161
if
_
,
err
:=
blockchain
.
InsertChain
(
types
.
Blocks
{
blocks
[
1
]});
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
blockchain
.
stateCache
.
Exist
(
theAddr
)
{
t
.
Error
(
"account should not expect"
)
}
// account musn't be created post eip 161
if
_
,
err
:=
blockchain
.
InsertChain
(
types
.
Blocks
{
blocks
[
2
]});
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
blockchain
.
stateCache
.
Exist
(
theAddr
)
{
t
.
Error
(
"account should not expect"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment