From 2a3743ff840aeecbb98f542b486a1b0fbaeaab1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Wed, 9 Sep 2020 14:08:54 +0100 Subject: [PATCH] invoke the statediff command properly. --- conformance/runner_test.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/conformance/runner_test.go b/conformance/runner_test.go index ca7fdfc63..a57458dcb 100644 --- a/conformance/runner_test.go +++ b/conformance/runner_test.go @@ -194,8 +194,10 @@ func executeMessageVector(t *testing.T, vector *schema.TestVector) { // Once all messages are applied, assert that the final state root matches // the expected postcondition root. - if root != vector.Post.StateTree.RootCID { + if expected, actual := vector.Post.StateTree.RootCID, root; expected != actual { + t.Logf("actual state root CID doesn't match expected one; expected: %s, actual: %s", expected, actual) dumpThreeWayStateDiff(t, vector, bs, root) + t.FailNow() } } @@ -239,8 +241,10 @@ func executeTipsetVector(t *testing.T, vector *schema.TestVector) { // Once all messages are applied, assert that the final state root matches // the expected postcondition root. - if root != vector.Post.StateTree.RootCID { + if expected, actual := vector.Post.StateTree.RootCID, root; expected != actual { + t.Logf("actual state root CID doesn't match expected one; expected: %s, actual: %s", expected, actual) dumpThreeWayStateDiff(t, vector, bs, root) + t.FailNow() } } @@ -290,26 +294,30 @@ func dumpThreeWayStateDiff(t *testing.T, vector *schema.TestVector, bs blockstor d1 = color.New(color.FgGreen, color.Bold).Sprint("[Δ1]") d2 = color.New(color.FgGreen, color.Bold).Sprint("[Δ2]") d3 = color.New(color.FgGreen, color.Bold).Sprint("[Δ3]") - - cmd *exec.Cmd ) + printDiff := func(left, right cid.Cid) { + cmd := exec.Command("statediff", "car", "--file", tmpCar, left.String(), right.String()) + b, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("statediff failed: %s", err) + } + t.Log(string(b)) + } + bold := color.New(color.Bold).SprintfFunc() // run state diffs. t.Log(bold("=== dumping 3-way diffs between %s, %s, %s ===", a, b, c)) t.Log(bold("--- %s left: %s; right: %s ---", d1, a, b)) - cmd = exec.Command("statediff", tmpCar, vector.Post.StateTree.RootCID.String(), actual.String()) - t.Log(cmd.CombinedOutput()) + printDiff(vector.Post.StateTree.RootCID, actual) t.Log(bold("--- %s left: %s; right: %s ---", d2, c, b)) - cmd = exec.Command("statediff", tmpCar, vector.Pre.StateTree.RootCID.String(), actual.String()) - t.Log(cmd.CombinedOutput()) + printDiff(vector.Pre.StateTree.RootCID, actual) t.Log(bold("--- %s left: %s; right: %s ---", d3, c, a)) - cmd = exec.Command("statediff", tmpCar, vector.Pre.StateTree.RootCID.String(), vector.Post.StateTree.RootCID.String()) - t.Log(cmd.CombinedOutput()) + printDiff(vector.Pre.StateTree.RootCID, vector.Post.StateTree.RootCID) } // writeStateToTempCAR writes the provided roots to a temporary CAR that'll be