Skip to content

Commit 8a02dbd

Browse files
iandarajasek
andauthored
Add diff logic between two AMTs (#48)
* Util to diff 2 AMTs * Adjust diff logic to refactored node types and variable bit widths * Remove outdated TODO * Simplify diff function signatures * Small stylistic and lint changes Co-authored-by: Aayush Rajasekaran <[email protected]>
1 parent 005fc97 commit 8a02dbd

File tree

5 files changed

+779
-12
lines changed

5 files changed

+779
-12
lines changed

amt_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ func init() {
3030
}
3131

3232
func TestMain(m *testing.M) {
33+
var exitCode int
34+
3335
// Hack to test with multiple widths, without hassle.
3436
for defaultBitWidth = 2; defaultBitWidth <= 18; defaultBitWidth++ {
3537
fmt.Printf("WIDTH %d\n", defaultBitWidth)
3638
if code := m.Run(); code != 0 {
37-
os.Exit(code)
39+
exitCode = code
3840
}
3941
}
40-
os.Exit(0)
42+
os.Exit(exitCode)
4143
}
4244

4345
type mockBlocks struct {
@@ -125,7 +127,6 @@ func TestBasicSetGet(t *testing.T) {
125127
assertGet(ctx, t, clean, 2, "foo")
126128

127129
assertCount(t, clean, 1)
128-
129130
}
130131

131132
func TestRoundTrip(t *testing.T) {
@@ -328,9 +329,9 @@ func TestChaos(t *testing.T) {
328329
bs := cbor.NewCborStore(newMockBlocks())
329330
seed := time.Now().UnixNano()
330331
ctx := context.Background()
331-
//seed = 1579200312848358622 // FIXED
332-
//seed = 1579202116615474412
333-
//seed = 1579202774458659521
332+
// seed = 1579200312848358622 // FIXED
333+
// seed = 1579202116615474412
334+
// seed = 1579202774458659521
334335
// all above are with ops=100,maxIndx=2000
335336
r := rand.New(rand.NewSource(seed))
336337
t.Logf("seed: %d", seed)
@@ -526,7 +527,7 @@ func TestDelete(t *testing.T) {
526527
assertDelete(t, a, 3)
527528

528529
assertCount(t, a, 0)
529-
fmt.Println("trying deeper operations now")
530+
t.Logf("trying deeper operations now")
530531

531532
assertSet(t, a, 23, "dog")
532533
assertSet(t, a, 24, "dog")
@@ -557,9 +558,9 @@ func TestDelete(t *testing.T) {
557558
}
558559

559560
if c != a2c {
560-
fmt.Printf("%#v\n", a)
561-
fmt.Printf("%#v\n", na)
562-
fmt.Printf("%#v\n", a2)
561+
t.Logf("%#v\n", a)
562+
t.Logf("%#v\n", na)
563+
t.Logf("%#v\n", a2)
563564
t.Fatal("unexpected cid", c, a2c)
564565
}
565566
}
@@ -833,7 +834,7 @@ func TestFirstSetIndex(t *testing.T) {
833834
found, err := after.Delete(ctx, v)
834835
require.NoError(t, err)
835836
require.True(t, found)
836-
fsi, err = after.FirstSetIndex(ctx)
837+
_, err = after.FirstSetIndex(ctx)
837838
require.Error(t, err)
838839
}
839840
}

0 commit comments

Comments
 (0)