@@ -37,15 +37,15 @@ var (
37
37
cachetestAccounts = []accounts.Account {
38
38
{
39
39
Address : common .HexToAddress ("7ef5a6135f1fd6a02593eedc869c6d41d934aef8" ),
40
- URL : filepath .Join (cachetestDir , "UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8" ),
40
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (cachetestDir , "UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8" )} ,
41
41
},
42
42
{
43
43
Address : common .HexToAddress ("f466859ead1932d743d622cb74fc058882e8648a" ),
44
- URL : filepath .Join (cachetestDir , "aaa" ),
44
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (cachetestDir , "aaa" )} ,
45
45
},
46
46
{
47
47
Address : common .HexToAddress ("289d485d9771714cce91d3393d764e1311907acc" ),
48
- URL : filepath .Join (cachetestDir , "zzz" ),
48
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (cachetestDir , "zzz" )} ,
49
49
},
50
50
}
51
51
)
@@ -63,10 +63,11 @@ func TestWatchNewFile(t *testing.T) {
63
63
// Move in the files.
64
64
wantAccounts := make ([]accounts.Account , len (cachetestAccounts ))
65
65
for i := range cachetestAccounts {
66
- a := cachetestAccounts [i ]
67
- a .URL = filepath .Join (dir , filepath .Base (a .URL ))
68
- wantAccounts [i ] = a
69
- if err := cp .CopyFile (a .URL , cachetestAccounts [i ].URL ); err != nil {
66
+ wantAccounts [i ] = accounts.Account {
67
+ Address : cachetestAccounts [i ].Address ,
68
+ URL : accounts.URL {Scheme : KeyStoreScheme , Path : filepath .Join (dir , filepath .Base (cachetestAccounts [i ].URL .Path ))},
69
+ }
70
+ if err := cp .CopyFile (wantAccounts [i ].URL .Path , cachetestAccounts [i ].URL .Path ); err != nil {
70
71
t .Fatal (err )
71
72
}
72
73
}
@@ -107,13 +108,13 @@ func TestWatchNoDir(t *testing.T) {
107
108
os .MkdirAll (dir , 0700 )
108
109
defer os .RemoveAll (dir )
109
110
file := filepath .Join (dir , "aaa" )
110
- if err := cp .CopyFile (file , cachetestAccounts [0 ].URL ); err != nil {
111
+ if err := cp .CopyFile (file , cachetestAccounts [0 ].URL . Path ); err != nil {
111
112
t .Fatal (err )
112
113
}
113
114
114
115
// ks should see the account.
115
116
wantAccounts := []accounts.Account {cachetestAccounts [0 ]}
116
- wantAccounts [0 ].URL = file
117
+ wantAccounts [0 ].URL = accounts. URL { Scheme : KeyStoreScheme , Path : file }
117
118
for d := 200 * time .Millisecond ; d < 8 * time .Second ; d *= 2 {
118
119
list = ks .Accounts ()
119
120
if reflect .DeepEqual (list , wantAccounts ) {
@@ -145,31 +146,31 @@ func TestCacheAddDeleteOrder(t *testing.T) {
145
146
accs := []accounts.Account {
146
147
{
147
148
Address : common .HexToAddress ("095e7baea6a6c7c4c2dfeb977efac326af552d87" ),
148
- URL : "-309830980" ,
149
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "-309830980" } ,
149
150
},
150
151
{
151
152
Address : common .HexToAddress ("2cac1adea150210703ba75ed097ddfe24e14f213" ),
152
- URL : "ggg" ,
153
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "ggg" } ,
153
154
},
154
155
{
155
156
Address : common .HexToAddress ("8bda78331c916a08481428e4b07c96d3e916d165" ),
156
- URL : "zzzzzz-the-very-last-one.keyXXX" ,
157
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "zzzzzz-the-very-last-one.keyXXX" } ,
157
158
},
158
159
{
159
160
Address : common .HexToAddress ("d49ff4eeb0b2686ed89c0fc0f2b6ea533ddbbd5e" ),
160
- URL : "SOMETHING.key" ,
161
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "SOMETHING.key" } ,
161
162
},
162
163
{
163
164
Address : common .HexToAddress ("7ef5a6135f1fd6a02593eedc869c6d41d934aef8" ),
164
- URL : "UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8" ,
165
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8" } ,
165
166
},
166
167
{
167
168
Address : common .HexToAddress ("f466859ead1932d743d622cb74fc058882e8648a" ),
168
- URL : "aaa" ,
169
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "aaa" } ,
169
170
},
170
171
{
171
172
Address : common .HexToAddress ("289d485d9771714cce91d3393d764e1311907acc" ),
172
- URL : "zzz" ,
173
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : "zzz" } ,
173
174
},
174
175
}
175
176
for _ , a := range accs {
@@ -210,7 +211,7 @@ func TestCacheAddDeleteOrder(t *testing.T) {
210
211
for i := 0 ; i < len (accs ); i += 2 {
211
212
cache .delete (wantAccounts [i ])
212
213
}
213
- cache .delete (accounts.Account {Address : common .HexToAddress ("fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e" ), URL : "something" })
214
+ cache .delete (accounts.Account {Address : common .HexToAddress ("fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e" ), URL : accounts. URL { Scheme : KeyStoreScheme , Path : "something" } })
214
215
215
216
select {
216
217
case <- notify :
@@ -245,19 +246,19 @@ func TestCacheFind(t *testing.T) {
245
246
accs := []accounts.Account {
246
247
{
247
248
Address : common .HexToAddress ("095e7baea6a6c7c4c2dfeb977efac326af552d87" ),
248
- URL : filepath .Join (dir , "a.key" ),
249
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (dir , "a.key" )} ,
249
250
},
250
251
{
251
252
Address : common .HexToAddress ("2cac1adea150210703ba75ed097ddfe24e14f213" ),
252
- URL : filepath .Join (dir , "b.key" ),
253
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (dir , "b.key" )} ,
253
254
},
254
255
{
255
256
Address : common .HexToAddress ("d49ff4eeb0b2686ed89c0fc0f2b6ea533ddbbd5e" ),
256
- URL : filepath .Join (dir , "c.key" ),
257
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (dir , "c.key" )} ,
257
258
},
258
259
{
259
260
Address : common .HexToAddress ("d49ff4eeb0b2686ed89c0fc0f2b6ea533ddbbd5e" ),
260
- URL : filepath .Join (dir , "c2.key" ),
261
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (dir , "c2.key" )} ,
261
262
},
262
263
}
263
264
for _ , a := range accs {
@@ -266,7 +267,7 @@ func TestCacheFind(t *testing.T) {
266
267
267
268
nomatchAccount := accounts.Account {
268
269
Address : common .HexToAddress ("f466859ead1932d743d622cb74fc058882e8648a" ),
269
- URL : filepath .Join (dir , "something" ),
270
+ URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Join (dir , "something" )} ,
270
271
}
271
272
tests := []struct {
272
273
Query accounts.Account
@@ -278,7 +279,7 @@ func TestCacheFind(t *testing.T) {
278
279
// by file
279
280
{Query : accounts.Account {URL : accs [0 ].URL }, WantResult : accs [0 ]},
280
281
// by basename
281
- {Query : accounts.Account {URL : filepath .Base (accs [0 ].URL ) }, WantResult : accs [0 ]},
282
+ {Query : accounts.Account {URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Base (accs [0 ].URL . Path )} }, WantResult : accs [0 ]},
282
283
// by file and address
283
284
{Query : accs [0 ], WantResult : accs [0 ]},
284
285
// ambiguous address, tie resolved by file
@@ -294,7 +295,7 @@ func TestCacheFind(t *testing.T) {
294
295
// no match error
295
296
{Query : nomatchAccount , WantError : ErrNoMatch },
296
297
{Query : accounts.Account {URL : nomatchAccount .URL }, WantError : ErrNoMatch },
297
- {Query : accounts.Account {URL : filepath .Base (nomatchAccount .URL ) }, WantError : ErrNoMatch },
298
+ {Query : accounts.Account {URL : accounts. URL { Scheme : KeyStoreScheme , Path : filepath .Base (nomatchAccount .URL . Path )} }, WantError : ErrNoMatch },
298
299
{Query : accounts.Account {Address : nomatchAccount .Address }, WantError : ErrNoMatch },
299
300
}
300
301
for i , test := range tests {
0 commit comments