@@ -12,10 +12,11 @@ import (
12
12
13
13
func TestCleanIPNSRecordsMigration (t * testing.T ) {
14
14
var (
15
- basePath = schema .GenerateTempPath ()
16
- ipnsKey = "/ipns/shoulddelete"
17
- otherKey = "/ipfs/shouldNOTdelete"
18
- migration = cleanIPNSRecordsFromDatastore {}
15
+ basePath = schema .GenerateTempPath ()
16
+ ipnsKey = "/ipns/shoulddelete"
17
+ ipnsFalsePositiveKey = "/ipns/persistentcache/shouldNOTdelete"
18
+ otherKey = "/ipfs/shouldNOTdelete"
19
+ migration = cleanIPNSRecordsFromDatastore {}
19
20
20
21
testRepoPath , err = schema .OpenbazaarPathTransform (basePath , true )
21
22
)
@@ -46,6 +47,10 @@ func TestCleanIPNSRecordsMigration(t *testing.T) {
46
47
if err != nil {
47
48
t .Fatal ("unable to put ipns record" )
48
49
}
50
+ err = r .Datastore ().Put (ds .NewKey (ipnsFalsePositiveKey ), []byte ("randomdata" ))
51
+ if err != nil {
52
+ t .Fatal ("unable to put other record" )
53
+ }
49
54
err = r .Datastore ().Put (ds .NewKey (otherKey ), []byte ("randomdata" ))
50
55
if err != nil {
51
56
t .Fatal ("unable to put other record" )
@@ -60,6 +65,13 @@ func TestCleanIPNSRecordsMigration(t *testing.T) {
60
65
if _ , err := r .Datastore ().Get (ds .NewKey (ipnsKey )); err != ds .ErrNotFound {
61
66
t .Errorf ("expected the IPNS record to be removed, but was not" )
62
67
}
68
+ if val , err := r .Datastore ().Get (ds .NewKey (ipnsFalsePositiveKey )); err != nil {
69
+ t .Errorf ("expected the false-positive record to be present, but was not" )
70
+ } else {
71
+ if ! bytes .Equal ([]byte ("randomdata" ), val ) {
72
+ t .Errorf ("expected the false-positive record data to be intact, but was not" )
73
+ }
74
+ }
63
75
if val , err := r .Datastore ().Get (ds .NewKey (otherKey )); err != nil {
64
76
t .Errorf ("expected the other record to be present, but was not" )
65
77
} else {
0 commit comments