1313
1414// You should have received a copy of the GNU General Public License
1515// along with Open Ethereum. If not, see <http://www.gnu.org/licenses/>.
16+ #![ allow( dead_code) ]
1617
1718use ethjson:: test_helpers:: ethspec:: {
1819 ChainTests , DifficultyTests , EthereumTestSuite , ExecutiveTests , StateTests , TestChainSpec ,
1920 TestTrieSpec , TransactionTests , TrieTests ,
2021} ;
2122use globset:: Glob ;
22- use log:: { info, warn } ;
23+ use log:: info;
2324use rayon:: prelude:: * ;
2425use std:: path:: { Path , PathBuf } ;
2526use tempfile:: tempdir;
2627use trie:: TrieSpec ;
2728use walkdir:: { DirEntry , WalkDir } ;
2829
30+ /// Result of tests execution
2931pub struct TestResult {
32+ /// Number of success execution
3033 pub success : usize ,
34+ /// Number of success execution
3135 pub failed : Vec < String > ,
3236}
3337
3438impl TestResult {
39+ /// Creates a new TestResult without results
3540 pub fn zero ( ) -> Self {
3641 TestResult {
3742 success : 0 ,
3843 failed : Vec :: new ( ) ,
3944 }
4045 }
46+ /// Creates a new success TestResult
4147 pub fn success ( ) -> Self {
4248 TestResult {
4349 success : 1 ,
4450 failed : Vec :: new ( ) ,
4551 }
4652 }
53+ /// Creates a new failed TestResult
4754 pub fn failed ( name : & str ) -> Self {
4855 TestResult {
4956 success : 0 ,
@@ -73,13 +80,15 @@ impl std::ops::AddAssign for TestResult {
7380pub struct TestRunner ( EthereumTestSuite ) ;
7481
7582impl TestRunner {
83+ /// Loads a new JSON Test suite
7684 pub fn load < R > ( reader : R ) -> Result < Self , serde_json:: Error >
7785 where
7886 R : std:: io:: Read ,
7987 {
8088 Ok ( TestRunner ( serde_json:: from_reader ( reader) ?) )
8189 }
8290
91+ /// Run the tests with one thread
8392 pub fn run_without_par ( & self ) -> TestResult {
8493 let pool = rayon:: ThreadPoolBuilder :: new ( )
8594 . num_threads ( 1 )
@@ -88,6 +97,7 @@ impl TestRunner {
8897 pool. install ( || self . run ( ) )
8998 }
9099
100+ /// Run the tests
91101 pub fn run ( & self ) -> TestResult {
92102 let mut res = TestResult :: zero ( ) ;
93103 for t in & self . 0 . chain {
@@ -120,10 +130,6 @@ impl TestRunner {
120130 . collect :: < Vec < PathBuf > > ( )
121131 }
122132
123- fn report_failed_tests ( path : & Path , list : & Vec < String > ) {
124- warn ! ( "FAILED TESTS FOR {:?}: {:?} " , path, list) ;
125- }
126-
127133 fn run1 < T , F > ( test : & T , base_path : & str , f : F ) -> TestResult
128134 where
129135 T : Send + Sync ,
@@ -149,7 +155,7 @@ impl TestRunner {
149155 result
150156 }
151157
152- pub fn in_set ( path : & Path , exprs : & [ String ] ) -> bool {
158+ fn in_set ( path : & Path , exprs : & [ String ] ) -> bool {
153159 for pathexp in exprs {
154160 let glob = Glob :: new ( & pathexp)
155161 . expect ( & format ! ( "cannot parse expression {}" , pathexp) )
@@ -161,7 +167,7 @@ impl TestRunner {
161167 false
162168 }
163169
164- pub fn run_chain_tests ( test : & ChainTests ) -> TestResult {
170+ fn run_chain_tests ( test : & ChainTests ) -> TestResult {
165171 Self :: run1 (
166172 test,
167173 & test. path ,
@@ -176,7 +182,8 @@ impl TestRunner {
176182 } ,
177183 )
178184 }
179- pub fn run_state_tests ( test : & StateTests ) -> TestResult {
185+
186+ fn run_state_tests ( test : & StateTests ) -> TestResult {
180187 Self :: run1 (
181188 test,
182189 & test. path ,
@@ -191,7 +198,8 @@ impl TestRunner {
191198 } ,
192199 )
193200 }
194- pub fn run_difficuly_tests ( test : & DifficultyTests ) -> TestResult {
201+
202+ fn run_difficuly_tests ( test : & DifficultyTests ) -> TestResult {
195203 let mut acc = TestResult :: zero ( ) ;
196204 for path in & test. path {
197205 acc += Self :: run1 (
@@ -213,7 +221,7 @@ impl TestRunner {
213221 acc
214222 }
215223
216- pub fn run_executive_tests ( test : & ExecutiveTests ) -> TestResult {
224+ fn run_executive_tests ( test : & ExecutiveTests ) -> TestResult {
217225 Self :: run1 (
218226 test,
219227 & test. path ,
@@ -222,16 +230,18 @@ impl TestRunner {
222230 } ,
223231 )
224232 }
225- pub fn run_transaction_tests ( test : & TransactionTests ) -> TestResult {
233+
234+ fn run_transaction_tests ( test : & TransactionTests ) -> TestResult {
226235 Self :: run1 (
227236 test,
228237 & test. path ,
229- |test : & TransactionTests , path : & Path , json : & [ u8 ] | {
238+ |_ : & TransactionTests , path : & Path , json : & [ u8 ] | {
230239 super :: transaction:: do_json_test ( & path, & json, & mut |_, _| { } )
231240 } ,
232241 )
233242 }
234- pub fn run_trie_tests ( test : & TrieTests ) -> TestResult {
243+
244+ fn run_trie_tests ( test : & TrieTests ) -> TestResult {
235245 let mut acc = TestResult :: zero ( ) ;
236246 for path in & test. path {
237247 acc += Self :: run1 ( test, & path, |test : & TrieTests , path : & Path , json : & [ u8 ] | {
0 commit comments