@@ -8,10 +8,11 @@ import Config from "@truffle/config";
88const config = Config . default ( ) ;
99let versionRangeOptions = {
1010 events : config . events ,
11- solcConfig : config . compilers . solc
11+ solcConfig : config . compilers . solc ,
12+ cache : "fileSystem"
1213} ;
1314const instance = new LoadingStrategies . VersionRange ( versionRangeOptions ) ;
14- let fileName , expectedResult ;
15+ let fileName : string , expectedResult : any ;
1516const compilerFileNames = [
1617 "soljson-v0.4.22+commit.124ca40d.js" ,
1718 "soljson-v0.4.23+commit.1534a40d.js" ,
@@ -105,32 +106,32 @@ describe("VersionRange loading strategy", () => {
105106
106107 describe ( "when a version constraint is specified" , ( ) => {
107108 beforeEach ( ( ) => {
108- sinon . stub ( instance , "getAndCacheSolcByUrl " ) ;
109- sinon . stub ( instance . cache , "has" ) . returns ( false ) ;
109+ sinon . stub ( instance , "getAndCacheSoljsonByUrl " ) ;
110+ sinon . stub ( instance . cache ! , "has" ) . returns ( false ) ;
110111 } ) ;
111112 afterEach ( ( ) => {
112- unStub ( instance , "getAndCacheSolcByUrl " ) ;
113- unStub ( instance . cache , "has" ) ;
113+ unStub ( instance , "getAndCacheSoljsonByUrl " ) ;
114+ unStub ( instance . cache ! , "has" ) ;
114115 } ) ;
115116
116117 it ( "calls findNewstValidVersion to determine which version to fetch" , async ( ) => {
117118 await instance . getSolcFromCacheOrUrl ( "^0.5.0" ) ;
118119 assert . isTrue (
119120 // @ts -ignore
120- instance . getAndCacheSolcByUrl . calledWith (
121+ instance . getAndCacheSoljsonByUrl . calledWith (
121122 "soljson-v0.5.4+commit.9549d8ff.js"
122123 ) ,
123- "getAndCacheSolcByUrl not called with the compiler file name"
124+ "getAndCacheSoljsonByUrl not called with the compiler file name"
124125 ) ;
125126 } ) ;
126127 } ) ;
127128
128129 describe ( "when the version is cached" , ( ) => {
129130 beforeEach ( ( ) => {
130- sinon . stub ( instance . cache , "has" ) . returns ( true ) ;
131+ sinon . stub ( instance . cache ! , "has" ) . returns ( true ) ;
131132 } ) ;
132133 afterEach ( ( ) => {
133- unStub ( instance . cache , "has" ) ;
134+ unStub ( instance . cache ! , "has" ) ;
134135 } ) ;
135136
136137 it ( "calls getCachedSolcByFileName" , async ( ) => {
@@ -146,13 +147,15 @@ describe("VersionRange loading strategy", () => {
146147
147148 describe ( "when the version is not cached" , ( ) => {
148149 beforeEach ( ( ) => {
149- sinon . stub ( instance . cache , "has" ) . returns ( false ) ;
150- sinon . stub ( instance . cache , "add" ) ;
151- sinon . stub ( instance , "compilerFromString" ) . returns ( "compiler" ) ;
150+ sinon . stub ( instance . cache ! , "has" ) . returns ( false ) ;
151+ sinon . stub ( instance . cache ! , "add" ) ;
152+ sinon
153+ . stub ( instance , "compilerFromString" )
154+ . returns ( Promise . resolve ( "compiler" ) ) ;
152155 } ) ;
153156 afterEach ( ( ) => {
154- unStub ( instance . cache , "has" ) ;
155- unStub ( instance . cache , "add" ) ;
157+ unStub ( instance . cache ! , "has" ) ;
158+ unStub ( instance . cache ! , "add" ) ;
156159 unStub ( instance , "compilerFromString" ) ;
157160 } ) ;
158161
@@ -178,16 +181,16 @@ describe("VersionRange loading strategy", () => {
178181 sinon
179182 . stub ( instance , "compilerFromString" )
180183 . withArgs ( "requestReturn" )
181- . returns ( "success" ) ;
184+ . returns ( Promise . resolve ( "success" ) ) ;
182185 } ) ;
183186 afterEach ( ( ) => {
184187 unStub ( axios , "get" ) ;
185- unStub ( instance . cache , "add" ) ;
188+ unStub ( instance . cache ! , "add" ) ;
186189 unStub ( instance , "compilerFromString" ) ;
187190 } ) ;
188191
189192 it ( "calls add with the response and the file name" , async ( ) => {
190- const result = await instance . getAndCacheSolcByUrl ( fileName , 0 ) ;
193+ const result = await instance . getAndCacheSoljsonByUrl ( fileName , 0 ) ;
191194 assert . isTrue (
192195 // @ts -ignore
193196 instance . cache . add . calledWith ( "requestReturn" , "someSolcFile" )
@@ -216,10 +219,10 @@ describe("VersionRange loading strategy", () => {
216219
217220 describe ( "versionIsCached(version)" , ( ) => {
218221 beforeEach ( ( ) => {
219- sinon . stub ( instance . cache , "list" ) . returns ( compilerFileNames ) ;
222+ sinon . stub ( instance . cache ! , "list" ) . returns ( compilerFileNames ) ;
220223 } ) ;
221224 afterEach ( ( ) => {
222- unStub ( instance . cache , "list" ) ;
225+ unStub ( instance . cache ! , "list" ) ;
223226 } ) ;
224227
225228 describe ( "when a cached version of the compiler is present" , ( ) => {
@@ -246,11 +249,11 @@ describe("VersionRange loading strategy", () => {
246249 describe ( "getCachedSolcByVersionRange(version)" , ( ) => {
247250 beforeEach ( ( ) => {
248251 expectedResult = "soljson-v0.4.23+commit.1534a40d.js" ;
249- sinon . stub ( instance . cache , "list" ) . returns ( compilerFileNames ) ;
252+ sinon . stub ( instance . cache ! , "list" ) . returns ( compilerFileNames ) ;
250253 sinon . stub ( instance , "getCachedSolcByFileName" ) ;
251254 } ) ;
252255 afterEach ( ( ) => {
253- unStub ( instance . cache , "list" ) ;
256+ unStub ( instance . cache ! , "list" ) ;
254257 unStub ( instance , "getCachedSolcByFileName" ) ;
255258 } ) ;
256259
0 commit comments