From b8ced9e00be1e0f7f774b154f19b58643b04df3c Mon Sep 17 00:00:00 2001
From: meows <b5c6@protonmail.com>
Date: Wed, 20 Nov 2019 07:54:18 -0500
Subject: [PATCH] tests: refactor TestState to dedupe walk callback

Minor refactoring.
---
 tests/state_test.go | 42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/tests/state_test.go b/tests/state_test.go
index c6a6947bc..f9499d4a8 100644
--- a/tests/state_test.go
+++ b/tests/state_test.go
@@ -53,33 +53,25 @@ func TestState(t *testing.T) {
 	//st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/ConstantinopleFix/0`, "bug in test")
 	//st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/ConstantinopleFix/3`, "bug in test")
 
-	st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
-		for _, subtest := range test.Subtests() {
-			subtest := subtest
-			key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
-			name := name + "/" + key
-			t.Run(key, func(t *testing.T) {
-				withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
-					_, err := test.Run(subtest, vmconfig)
-					return st.checkFailure(t, name, err)
-				})
-			})
-		}
-	})
 	// For Istanbul, older tests were moved into LegacyTests
-	st.walk(t, legacyStateTestDir, func(t *testing.T, name string, test *StateTest) {
-		for _, subtest := range test.Subtests() {
-			subtest := subtest
-			key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
-			name := name + "/" + key
-			t.Run(key, func(t *testing.T) {
-				withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
-					_, err := test.Run(subtest, vmconfig)
-					return st.checkFailure(t, name, err)
+	for _, dir := range []string{
+		stateTestDir,
+		legacyStateTestDir,
+	} {
+		st.walk(t, dir, func(t *testing.T, name string, test *StateTest) {
+			for _, subtest := range test.Subtests() {
+				subtest := subtest
+				key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
+				name := name + "/" + key
+				t.Run(key, func(t *testing.T) {
+					withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
+						_, err := test.Run(subtest, vmconfig)
+						return st.checkFailure(t, name, err)
+					})
 				})
-			})
-		}
-	})
+			}
+		})
+	}
 }
 
 // Transactions with gasLimit above this value will not get a VM trace on failure.
-- 
GitLab