This repository was archived by the owner on Jun 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -105,3 +105,43 @@ func TestRecurivePathResolution(t *testing.T) {
105
105
p .String (), rCid .String (), cKey .String ()))
106
106
}
107
107
}
108
+
109
+ func TestResolveToLastNode_NoUnnecessaryFetching (t * testing.T ) {
110
+ ctx := context .Background ()
111
+ dagService := dagmock .Mock ()
112
+
113
+ a := randNode ()
114
+ b := randNode ()
115
+
116
+ err := a .AddNodeLink ("child" , b )
117
+ if err != nil {
118
+ t .Fatal (err )
119
+ }
120
+
121
+ err = dagService .Add (ctx , a )
122
+ if err != nil {
123
+ t .Fatal (err )
124
+ }
125
+
126
+ aKey := a .Cid ()
127
+
128
+ segments := []string {aKey .String (), "child" }
129
+ p , err := path .FromSegments ("/ipfs/" , segments ... )
130
+ if err != nil {
131
+ t .Fatal (err )
132
+ }
133
+
134
+ resolver := resolver .NewBasicResolver (dagService )
135
+ resolvedCID , remainingPath , err := resolver .ResolveToLastNode (ctx , p )
136
+ if err != nil {
137
+ t .Fatal (err )
138
+ }
139
+
140
+ if len (remainingPath ) > 0 {
141
+ t .Fatal ("cannot have remaining path" )
142
+ }
143
+
144
+ if ! resolvedCID .Equals (b .Cid ()) {
145
+ t .Fatal ("resolved to the wrong CID" )
146
+ }
147
+ }
You can’t perform that action at this time.
0 commit comments