@@ -38,6 +38,7 @@ pub enum ForkSpec {
38
38
39
39
/// Spec deserialization.
40
40
#[ derive( Debug , PartialEq , Deserialize ) ]
41
+ #[ serde( deny_unknown_fields) ]
41
42
#[ serde( rename_all = "camelCase" ) ]
42
43
pub struct Spec {
43
44
/// Spec name.
@@ -70,6 +71,71 @@ mod tests {
70
71
use serde_json;
71
72
use spec:: spec:: Spec ;
72
73
74
+ #[ test]
75
+ fn should_error_on_unknown_fields ( ) {
76
+ let s = r#"{
77
+ "name": "Morden",
78
+ "dataDir": "morden",
79
+ "engine": {
80
+ "Ethash": {
81
+ "params": {
82
+ "minimumDifficulty": "0x020000",
83
+ "difficultyBoundDivisor": "0x0800",
84
+ "durationLimit": "0x0d",
85
+ "homesteadTransition" : "0x",
86
+ "daoHardforkTransition": "0xffffffffffffffff",
87
+ "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000",
88
+ "daoHardforkAccounts": []
89
+ }
90
+ }
91
+ },
92
+ "params": {
93
+ "accountStartNonce": "0x0100000",
94
+ "maximumExtraDataSize": "0x20",
95
+ "minGasLimit": "0x1388",
96
+ "networkID" : "0x2",
97
+ "forkBlock": "0xffffffffffffffff",
98
+ "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
99
+ "gasLimitBoundDivisor": "0x20",
100
+ "unknownField": "0x0"
101
+ },
102
+ "genesis": {
103
+ "seal": {
104
+ "ethereum": {
105
+ "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
106
+ "nonce": "0x00006d6f7264656e"
107
+ }
108
+ },
109
+ "difficulty": "0x20000",
110
+ "author": "0x0000000000000000000000000000000000000000",
111
+ "timestamp": "0x00",
112
+ "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
113
+ "extraData": "0x",
114
+ "gasLimit": "0x2fefd8"
115
+ },
116
+ "nodes": [
117
+ "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
118
+ ],
119
+ "accounts": {
120
+ "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
121
+ "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
122
+ "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
123
+ "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
124
+ "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
125
+ },
126
+ "hardcodedSync": {
127
+ "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23",
128
+ "totalDifficulty": "0x400000000",
129
+ "CHTs": [
130
+ "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
131
+ "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"
132
+ ]
133
+ }
134
+ }"# ;
135
+ let result: Result < Spec , _ > = serde_json:: from_str ( s) ;
136
+ assert ! ( result. is_err( ) ) ;
137
+ }
138
+
73
139
#[ test]
74
140
fn spec_deserialization ( ) {
75
141
let s = r#"{
@@ -90,7 +156,6 @@ mod tests {
90
156
},
91
157
"params": {
92
158
"accountStartNonce": "0x0100000",
93
- "homesteadTransition": "0x789b0",
94
159
"maximumExtraDataSize": "0x20",
95
160
"minGasLimit": "0x1388",
96
161
"networkID" : "0x2",
0 commit comments