From 2eb6fb030844d2cf57f4d111b1b08129a74ccefd Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Fri, 29 Sep 2023 08:57:43 +0300 Subject: [PATCH 01/20] Update cadence dependency to latest master commit --- test/go.mod | 6 +++++- test/go.sum | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/go.mod b/test/go.mod index 1ee81778..b58dce37 100644 --- a/test/go.mod +++ b/test/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/logrusorgru/aurora v2.0.3+incompatible - github.com/onflow/cadence v0.40.1-0.20230906152939-75f661676745 + github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 github.com/onflow/flow-emulator v0.54.0 github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 github.com/onflow/flow-go-sdk v0.41.10 @@ -63,9 +63,12 @@ require ( github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect github.com/jbenet/goprocess v0.1.4 // indirect + github.com/k0kubun/pp/v3 v3.2.0 // indirect github.com/kevinburke/go-bindata v3.23.0+incompatible // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-libp2p v0.28.1 // indirect github.com/logrusorgru/aurora/v4 v4.0.0 // indirect @@ -110,6 +113,7 @@ require ( github.com/psiemens/sconfig v0.1.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/schollz/progressbar/v3 v3.13.1 // indirect github.com/sethvargo/go-retry v0.2.3 // indirect github.com/slok/go-http-metrics v0.10.0 // indirect diff --git a/test/go.sum b/test/go.sum index 9b91f357..d5bb3c79 100644 --- a/test/go.sum +++ b/test/go.sum @@ -145,6 +145,7 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -402,6 +403,8 @@ github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= +github.com/k0kubun/pp/v3 v3.2.0 h1:h33hNTZ9nVFNP3u2Fsgz8JXiF5JINoZfFq4SvKJwNcs= +github.com/k0kubun/pp/v3 v3.2.0/go.mod h1:ODtJQbQcIRfAD3N+theGCV1m/CBxweERz2dapdz1EwA= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= github.com/kevinburke/go-bindata v3.23.0+incompatible h1:rqNOXZlqrYhMVVAsQx8wuc+LaA73YcfbQ407wAykyS8= @@ -422,9 +425,11 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= @@ -521,6 +526,8 @@ github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVF github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= github.com/onflow/cadence v0.40.1-0.20230906152939-75f661676745 h1:a0KwLSP0Z5aPgQupEqQfDz1ly7WaEX4MU5yV3drTxNc= github.com/onflow/cadence v0.40.1-0.20230906152939-75f661676745/go.mod h1:2ggmhENvPPZXRnv9SmqN2xiYvluu4wx/96GCpeRh8lU= +github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 h1:olRNAL60z/xUq+IWc9tUZdciTHNgfFDinqyE++oGZ9A= +github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20230703193002-53362441b57d h1:B7PdhdUNkve5MVrekWDuQf84XsGBxNZ/D3x+QQ8XeVs= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20230703193002-53362441b57d/go.mod h1:xAiV/7TKhw863r6iO3CS5RnQ4F+pBY1TxD272BsILlo= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3 h1:X25A1dNajNUtE+KoV76wQ6BR6qI7G65vuuRXxDDqX7E= @@ -565,6 +572,7 @@ github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -608,6 +616,8 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= From c0f4116d212d27b649b3113352c0a2830c9a99b9 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Fri, 29 Sep 2023 09:01:24 +0300 Subject: [PATCH 02/20] Update flow-emulator dependency to latest master commit --- test/go.mod | 2 +- test/go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/go.mod b/test/go.mod index b58dce37..2ac989ec 100644 --- a/test/go.mod +++ b/test/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/logrusorgru/aurora v2.0.3+incompatible github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 - github.com/onflow/flow-emulator v0.54.0 + github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 github.com/onflow/flow-go-sdk v0.41.10 github.com/rs/zerolog v1.29.0 diff --git a/test/go.sum b/test/go.sum index d5bb3c79..e560d8fc 100644 --- a/test/go.sum +++ b/test/go.sum @@ -534,6 +534,8 @@ github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3 h1:X25A1dNajNUtE+K github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3/go.mod h1:dqAUVWwg+NlOhsuBHex7bEWmsUjsiExzhe/+t4xNH6A= github.com/onflow/flow-emulator v0.54.0 h1:GzqMPIjsNweiyBORs8naUXhgs3PhD0X4Ep4j/kGelq0= github.com/onflow/flow-emulator v0.54.0/go.mod h1:cPKNx2eaxUDtXNHN9nnrt/qydWUHNQRTa/9QnsaCSpo= +github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 h1:H7NfRcYc4lYJXb7N1YZN22f6SFAJQ0d8rXPKnQH+keE= +github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378/go.mod h1:cPKNx2eaxUDtXNHN9nnrt/qydWUHNQRTa/9QnsaCSpo= github.com/onflow/flow-ft/lib/go/contracts v0.7.0 h1:XEKE6qJUw3luhsYmIOteXP53gtxNxrwTohgxJXCYqBE= github.com/onflow/flow-ft/lib/go/contracts v0.7.0/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU= github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 h1:SJS/WqckE6lcXmCOL/7Gp39zY66mCcEhy9xfmyomKrw= From 898e17d2b1c4a20ea32f0cf7699a99e322351356 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Fri, 29 Sep 2023 09:02:44 +0300 Subject: [PATCH 03/20] Run go mod tidy --- test/go.mod | 12 +----------- test/go.sum | 40 +--------------------------------------- 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/test/go.mod b/test/go.mod index 2ac989ec..3fdb0c73 100644 --- a/test/go.mod +++ b/test/go.mod @@ -3,7 +3,6 @@ module github.com/onflow/cadence-tools/test go 1.18 require ( - github.com/logrusorgru/aurora v2.0.3+incompatible github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 @@ -33,13 +32,9 @@ require ( github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect github.com/glebarez/go-sqlite v1.21.1 // indirect - github.com/go-kit/kit v0.12.0 // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect - github.com/go-test/deep v1.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.0 // indirect github.com/golang/protobuf v1.5.3 // indirect @@ -71,14 +66,13 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-libp2p v0.28.1 // indirect + github.com/logrusorgru/aurora v2.0.3+incompatible // indirect github.com/logrusorgru/aurora/v4 v4.0.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect @@ -98,7 +92,6 @@ require ( github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230628215638-83439d22e0ce // indirect github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect github.com/onflow/sdks v0.5.0 // indirect - github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect @@ -114,7 +107,6 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect - github.com/schollz/progressbar/v3 v3.13.1 // indirect github.com/sethvargo/go-retry v0.2.3 // indirect github.com/slok/go-http-metrics v0.10.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect @@ -124,7 +116,6 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.15.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d // indirect @@ -149,7 +140,6 @@ require ( golang.org/x/net v0.10.0 // indirect golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.9.0 // indirect - golang.org/x/term v0.9.0 // indirect golang.org/x/text v0.10.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gonum.org/v1/gonum v0.13.0 // indirect diff --git a/test/go.sum b/test/go.sum index e560d8fc..87141062 100644 --- a/test/go.sum +++ b/test/go.sum @@ -27,18 +27,14 @@ cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aD cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k= cloud.google.com/go/kms v1.0.0/go.mod h1:nhUehi+w7zht2XrUfvTRNpxrfayBHqP4lu2NSywui/0= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= @@ -50,7 +46,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.28.1 h1:F5QDG5ChchaAVQhINh24U99OWHURqrW8OmQcGKXcbgI= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= @@ -81,13 +76,6 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.1 h1:VGkV9KmhGqOQWnHyi4gLG98kE6OecT42fdrCGFWxJsc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.3.0 h1:gceOysEWNNwLd6cki65IMBZ4WAM0MwgBQq2n7kejoT8= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 h1:5LHn8JQ0qvjD9L9JhMtylnkcw7j05GDZqM9Oin6hpr0= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.7.0 h1:HWsM0YQWX76V6MOp07YuTYacm8k7h69ObJuw7Nck+og= -github.com/aws/aws-sdk-go-v2/service/s3 v1.15.0 h1:nPLfLPfglacc29Y949sDxpr3X/blaY40s3B85WT2yZU= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -200,8 +188,6 @@ github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c/go.mod h1:TA1x github.com/fxamacker/circlehash v0.1.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA= github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= -github.com/gammazero/deque v0.1.0 h1:f9LnNmq66VDeuAlSAapemq/U7hJ2jpIWa4c09q8Dlik= -github.com/gammazero/workerpool v1.1.2 h1:vuioDQbgrz4HoaCi2q1HLlOXdpbap5AET7xu5/qj87g= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= @@ -211,13 +197,10 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -229,8 +212,6 @@ github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= -github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= -github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -245,7 +226,6 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -320,14 +300,11 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.7.1 h1:gF4c0zjUP2H/s/hEGyLA3I0fA2ZWjzYiONAD6cvPr8A= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= @@ -394,7 +371,6 @@ github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0 github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -463,7 +439,6 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -472,7 +447,6 @@ github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -524,16 +498,12 @@ github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x github.com/onflow/atree v0.6.0 h1:j7nQ2r8npznx4NX39zPpBYHmdy45f4xwoi+dm37Jk7c= github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVFi0tc= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.40.1-0.20230906152939-75f661676745 h1:a0KwLSP0Z5aPgQupEqQfDz1ly7WaEX4MU5yV3drTxNc= -github.com/onflow/cadence v0.40.1-0.20230906152939-75f661676745/go.mod h1:2ggmhENvPPZXRnv9SmqN2xiYvluu4wx/96GCpeRh8lU= github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 h1:olRNAL60z/xUq+IWc9tUZdciTHNgfFDinqyE++oGZ9A= github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20230703193002-53362441b57d h1:B7PdhdUNkve5MVrekWDuQf84XsGBxNZ/D3x+QQ8XeVs= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20230703193002-53362441b57d/go.mod h1:xAiV/7TKhw863r6iO3CS5RnQ4F+pBY1TxD272BsILlo= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3 h1:X25A1dNajNUtE+KoV76wQ6BR6qI7G65vuuRXxDDqX7E= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3/go.mod h1:dqAUVWwg+NlOhsuBHex7bEWmsUjsiExzhe/+t4xNH6A= -github.com/onflow/flow-emulator v0.54.0 h1:GzqMPIjsNweiyBORs8naUXhgs3PhD0X4Ep4j/kGelq0= -github.com/onflow/flow-emulator v0.54.0/go.mod h1:cPKNx2eaxUDtXNHN9nnrt/qydWUHNQRTa/9QnsaCSpo= github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 h1:H7NfRcYc4lYJXb7N1YZN22f6SFAJQ0d8rXPKnQH+keE= github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378/go.mod h1:cPKNx2eaxUDtXNHN9nnrt/qydWUHNQRTa/9QnsaCSpo= github.com/onflow/flow-ft/lib/go/contracts v0.7.0 h1:XEKE6qJUw3luhsYmIOteXP53gtxNxrwTohgxJXCYqBE= @@ -556,7 +526,6 @@ github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207 github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8= github.com/onflow/sdks v0.5.0/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d h1:gAEqYPn3DS83rHIKEpsajnppVD1+zwuYPFyeDVFaQvg= -github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= @@ -617,7 +586,6 @@ github.com/robertkrimen/otto v0.0.0-20170205013659-6a77b7cbc37d/go.mod h1:xvqspo github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= @@ -630,7 +598,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/schollz/progressbar/v3 v3.8.3/go.mod h1:pWnVCjSBZsT2X3nx9HfRdnCDrpbevliMeoEVhStwHko= github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE= -github.com/schollz/progressbar/v3 v3.13.1/go.mod h1:xvrbki8kfT1fzWzBT/UZd9L6GA+jdL7HAgq2RFnO6fQ= github.com/sethvargo/go-retry v0.2.3 h1:oYlgvIvsju3jNbottWABtbnoLC+GDtLdBHxKWxQm/iU= github.com/sethvargo/go-retry v0.2.3/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -712,8 +679,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY= github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= +github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/blake3 v0.2.0/go.mod h1:G9pM4qQwjRzF1/v7+vabMj/c5mWpGZ2Wzo3Eb4z0pb4= github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= @@ -728,7 +695,6 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= @@ -881,7 +847,6 @@ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -970,9 +935,7 @@ golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= -golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1090,7 +1053,6 @@ google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.58.0/go.mod h1:cAbP2FsxoGVNwtgNAmmn3y5G1TWAiVYRmg4yku3lv+E= -google.golang.org/api v0.114.0 h1:1xQPji6cO2E2vLiI+C/XiFAnsn1WV3mjaEwGLhi3grE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= From 1742d393c078ada3dc3ea901999b0d2828e3eb20 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Tue, 19 Sep 2023 12:28:04 +0300 Subject: [PATCH 04/20] Unify backend environment for Unit & Integration tests --- test/blockchain_helpers.cdc | 130 ++- test/emulator_backend.go | 390 +++++---- test/test_framework_provider.go | 17 +- test/test_framework_test.go | 1378 ++++++++++++++++++------------- test/test_runner.go | 217 +++-- 5 files changed, 1261 insertions(+), 871 deletions(-) diff --git a/test/blockchain_helpers.cdc b/test/blockchain_helpers.cdc index 3e44b2dc..c6d74369 100644 --- a/test/blockchain_helpers.cdc +++ b/test/blockchain_helpers.cdc @@ -1,80 +1,76 @@ import Test -pub struct BlockchainHelpers { - pub let blockchain: Test.Blockchain +/// Returns the current block height of the blockchain. +/// +access(all) +fun getCurrentBlockHeight(): UInt64 { + let script = readFile("get_current_block_height.cdc") + let scriptResult = Test.executeScript(script, []) - init(blockchain: Test.Blockchain) { - self.blockchain = blockchain - } - - /// Returns the current block height of the blockchain. - /// - pub fun getCurrentBlockHeight(): UInt64 { - let script = self.readFile("get_current_block_height.cdc") - let scriptResult = self.blockchain.executeScript(script, []) - - if scriptResult.status == Test.ResultStatus.failed { - panic(scriptResult.error!.message) - } - return scriptResult.returnValue! as! UInt64 + if scriptResult.status == Test.ResultStatus.failed { + panic(scriptResult.error!.message) } + return scriptResult.returnValue! as! UInt64 +} - /// Returns the Flow token balance for the given account. - /// - pub fun getFlowBalance(for account: Test.Account): UFix64 { - let script = self.readFile("get_flow_balance.cdc") - let scriptResult = self.blockchain.executeScript(script, [account.address]) +/// Returns the Flow token balance for the given account. +/// +access(all) +fun getFlowBalance(for account: Test.Account): UFix64 { + let script = readFile("get_flow_balance.cdc") + let scriptResult = Test.executeScript(script, [account.address]) - if scriptResult.status == Test.ResultStatus.failed { - panic(scriptResult.error!.message) - } - return scriptResult.returnValue! as! UFix64 + if scriptResult.status == Test.ResultStatus.failed { + panic(scriptResult.error!.message) } + return scriptResult.returnValue! as! UFix64 +} - /// Mints the given amount of Flow tokens to a specified test account. - /// The transaction is authorized and signed by the service account. - /// Returns the result of the transaction. - /// - pub fun mintFlow( - to receiver: Test.Account, - amount: UFix64 - ): Test.TransactionResult { - let code = self.readFile("mint_flow.cdc") - let tx = Test.Transaction( - code: code, - authorizers: [self.blockchain.serviceAccount().address], - signers: [], - arguments: [receiver.address, amount] - ) +/// Mints the given amount of Flow tokens to a specified test account. +/// The transaction is authorized and signed by the service account. +/// Returns the result of the transaction. +/// +access(all) +fun mintFlow( + to receiver: Test.Account, + amount: UFix64 +): Test.TransactionResult { + let code = readFile("mint_flow.cdc") + let tx = Test.Transaction( + code: code, + authorizers: [Test.serviceAccount().address], + signers: [], + arguments: [receiver.address, amount] + ) - return self.blockchain.executeTransaction(tx) - } + return Test.executeTransaction(tx) +} - /// Burns the specified amount of Flow tokens for the given - /// test account. Returns the result of the transaction. - /// - pub fun burnFlow( - from account: Test.Account, - amount: UFix64 - ): Test.TransactionResult { - let code = self.readFile("burn_flow.cdc") - let tx = Test.Transaction( - code: code, - authorizers: [account.address], - signers: [account], - arguments: [amount] - ) +/// Burns the specified amount of Flow tokens for the given +/// test account. Returns the result of the transaction. +/// +access(all) +fun burnFlow( + from account: Test.Account, + amount: UFix64 +): Test.TransactionResult { + let code = readFile("burn_flow.cdc") + let tx = Test.Transaction( + code: code, + authorizers: [account.address], + signers: [account], + arguments: [amount] + ) - return self.blockchain.executeTransaction(tx) - } + return Test.executeTransaction(tx) +} - /// Reads the code for the script/transaction with the given - /// file name and returns its content as a String. - /// - access(self) - fun readFile(_ name: String): String { - // The "\u{0}helper/" prefix is used in order to prevent - // conflicts with user-defined scripts/transactions. - return Test.readFile("\u{0}helper/".concat(name)) - } +/// Reads the code for the script/transaction with the given +/// file name and returns its content as a String. +/// +access(self) +fun readFile(_ name: String): String { + // The "\u{0}helper/" prefix is used in order to prevent + // conflicts with user-defined scripts/transactions. + return Test.readFile("\u{0}helper/".concat(name)) } diff --git a/test/emulator_backend.go b/test/emulator_backend.go index ef304e2e..39eacdce 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -52,6 +52,10 @@ import ( // conflicts with user-defined scripts/transactions. const helperFilePrefix = "\x00helper/" +// The number of predefined accounts that are created +// upon initialization of EmulatorBackend. +const initialAccountsNumber = 25 + var _ stdlib.Blockchain = &EmulatorBackend{} type systemClock struct { @@ -66,11 +70,17 @@ func newSystemClock() *systemClock { return &systemClock{} } +// This type holds the necessary information for each contract deployment. +// These are consumed in InterpreterConfig.ContractValueHandler function, +// in order to construct the contract value for imported contracts in +// test scripts. type deployedContractConstructorInvocation struct { ConstructorArguments []interpreter.Value ArgumentTypes []sema.Type + Address common.Address } +// This slice records all contract deployments in test scripts. var contractInvocations = make( map[string]deployedContractConstructorInvocation, 0, @@ -88,10 +98,6 @@ type EmulatorBackend struct { // accountKeys is a mapping of account addresses with their keys. accountKeys map[common.Address]map[string]keyInfo - // A property bag to pass various configurations to the backend. - // Currently, supports passing address mapping for contracts. - configuration *stdlib.Configuration - stdlibHandler stdlib.StandardLibraryHandler // logCollection is a hook attached in the server logger, in order @@ -100,6 +106,18 @@ type EmulatorBackend struct { // clock allows manipulating the blockchain's clock. clock *systemClock + + // accounts is a mapping of account addresses to the underlying + // stdlib.Account value. + accounts map[common.Address]*stdlib.Account + + // fileResolver is used to retrieve the Cadence source code, + // given a relative path. + fileResolver FileResolver + + // contracts is a mapping of contract identifiers to their + // deployed account address. + contracts map[string]common.Address } type keyInfo struct { @@ -160,15 +178,19 @@ func NewEmulatorBackend( clock := newSystemClock() blockchain.SetClock(clock) - return &EmulatorBackend{ + emulatorBackend := &EmulatorBackend{ blockchain: blockchain, blockOffset: 0, accountKeys: map[common.Address]map[string]keyInfo{}, - configuration: baseConfiguration(), stdlibHandler: stdlibHandler, logCollection: logCollectionHook, clock: clock, + contracts: map[string]common.Address{}, + accounts: map[common.Address]*stdlib.Account{}, } + emulatorBackend.bootstrapAccounts() + + return emulatorBackend } func (e *EmulatorBackend) RunScript( @@ -293,13 +315,26 @@ func (e *EmulatorBackend) CreateAccount() (*stdlib.Account, error) { }, } - return &stdlib.Account{ + account := &stdlib.Account{ Address: common.Address(address), PublicKey: &stdlib.PublicKey{ PublicKey: publicKey, SignAlgo: fvmCrypto.CryptoToRuntimeSigningAlgorithm(accountKey.PublicKey.Algorithm()), }, - }, nil + } + e.accounts[account.Address] = account + + return account, nil +} + +func (e *EmulatorBackend) GetAccount( + address interpreter.AddressValue, +) (*stdlib.Account, error) { + account, ok := e.accounts[address.ToAddress()] + if !ok { + return nil, fmt.Errorf("account with address: %s not found", address.Hex()) + } + return account, nil } func (e *EmulatorBackend) AddTransaction( @@ -343,58 +378,6 @@ func (e *EmulatorBackend) AddTransaction( return nil } -func (e *EmulatorBackend) newTransaction(code string, authorizers []common.Address) *sdk.Transaction { - serviceKey := e.blockchain.ServiceKey() - - sequenceNumber := serviceKey.SequenceNumber + e.blockOffset - - tx := sdk.NewTransaction(). - SetScript([]byte(code)). - SetProposalKey(serviceKey.Address, serviceKey.Index, sequenceNumber). - SetPayer(serviceKey.Address) - - for _, authorizer := range authorizers { - tx = tx.AddAuthorizer(sdk.Address(authorizer)) - } - - return tx -} - -func (e *EmulatorBackend) signTransaction( - tx *sdk.Transaction, - signerAccounts []*stdlib.Account, -) error { - - // Sign transaction with each signer - // Note: Following logic is borrowed from the flow-ft. - - for i := len(signerAccounts) - 1; i >= 0; i-- { - signerAccount := signerAccounts[i] - - publicKey := signerAccount.PublicKey.PublicKey - accountKeys := e.accountKeys[signerAccount.Address] - keyInfo := accountKeys[string(publicKey)] - - err := tx.SignPayload(sdk.Address(signerAccount.Address), 0, keyInfo.signer) - if err != nil { - return err - } - } - - serviceKey := e.blockchain.ServiceKey() - serviceSigner, err := serviceKey.Signer() - if err != nil { - return err - } - - err = tx.SignEnvelope(serviceKey.Address, 0, serviceSigner) - if err != nil { - return err - } - - return nil -} - func (e *EmulatorBackend) ExecuteNextTransaction() *stdlib.TransactionResult { result, err := e.blockchain.ExecuteNextTransaction() @@ -431,18 +414,23 @@ func (e *EmulatorBackend) CommitBlock() error { func (e *EmulatorBackend) DeployContract( inter *interpreter.Interpreter, name string, - code string, - account *stdlib.Account, + path string, args []interpreter.Value, ) error { const deployContractTransactionTemplate = ` - transaction(%s) { - prepare(signer: AuthAccount) { - signer.contracts.add(name: "%s", code: "%s".decodeHex()%s) - } - }` - + transaction(%s) { + prepare(signer: AuthAccount) { + signer.contracts.add(name: "%s", code: "%s".decodeHex()%s) + } + } + ` + + // Retrieve the contract source code, by using the given path. + code, err := e.fileResolver(path) + if err != nil { + panic(err) + } code = e.replaceImports(code) hexEncodedCode := hex.EncodeToString([]byte(code)) @@ -475,6 +463,14 @@ func (e *EmulatorBackend) DeployContract( addArgsBuilder.String(), ) + address, ok := e.contracts[name] + if !ok { + return fmt.Errorf("could not find the address of contract: %s", name) + } + account, ok := e.accounts[address] + if !ok { + return fmt.Errorf("could not find an account with address: %s", address) + } tx := e.newTransaction(script, []common.Address{account.Address}) for _, arg := range cadenceArgs { @@ -484,7 +480,7 @@ func (e *EmulatorBackend) DeployContract( } } - err := e.signTransaction(tx, []*stdlib.Account{account}) + err = e.signTransaction(tx, []*stdlib.Account{account}) if err != nil { return err } @@ -512,9 +508,13 @@ func (e *EmulatorBackend) DeployContract( } argTypes = append(argTypes, argType) } + // We record the successful contract deployment, along with any + // supplied arguments, so that we can reconstruct a contract value + // in test scripts. contractInvocations[name] = deployedContractConstructorInvocation{ ConstructorArguments: args, ArgumentTypes: argTypes, + Address: account.Address, } return e.CommitBlock() @@ -525,93 +525,6 @@ func (e *EmulatorBackend) Logs() []string { return e.logCollection.Logs } -// newBlockchain returns an emulator blockchain for testing. -func newBlockchain( - hook *logCollectionHook, - opts ...emulator.Option, -) *emulator.Blockchain { - output := zerolog.ConsoleWriter{Out: os.Stdout} - logger := zerolog.New(output).With().Timestamp(). - Logger().Hook(hook).Level(zerolog.InfoLevel) - - b, err := emulator.New( - append( - []emulator.Option{ - emulator.WithStorageLimitEnabled(false), - emulator.WithServerLogger(logger), - emulator.Contracts(commonContracts), - emulator.WithChainID(chain.ChainID()), - }, - opts..., - )..., - ) - if err != nil { - panic(err) - } - - return b -} - -func (e *EmulatorBackend) UseConfiguration(configuration *stdlib.Configuration) { - for contract, address := range configuration.Addresses { - // We do not want to override the base configuration, - // which includes the mapping for system/common contracts. - e.configuration.Addresses[contract] = address - } -} - -func (e *EmulatorBackend) replaceImports(code string) string { - if e.configuration == nil { - return code - } - - program, err := parser.ParseProgram(nil, []byte(code), parser.Config{}) - if err != nil { - panic(err) - } - - sb := strings.Builder{} - importDeclEnd := 0 - - for _, importDeclaration := range program.ImportDeclarations() { - prevImportDeclEnd := importDeclEnd - importDeclEnd = importDeclaration.EndPos.Offset + 1 - - location, ok := importDeclaration.Location.(common.StringLocation) - if !ok { - // keep the import statement it as-is - sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) - continue - } - - address, ok := e.configuration.Addresses[location.String()] - if !ok { - // keep import statement it as-is - sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) - continue - } - - var addressStr string - if strings.Contains(importDeclaration.String(), "from") { - addressStr = fmt.Sprintf("0x%s", address) - } else { - // Imports of the form `import "FungibleToken"` should be - // expanded to `import FungibleToken from 0xee82856bf20e2aa6` - addressStr = fmt.Sprintf("%s from 0x%s", location, address) - } - - locationStart := importDeclaration.LocationPos.Offset - - sb.WriteString(code[prevImportDeclEnd:locationStart]) - sb.WriteString(addressStr) - - } - - sb.WriteString(code[importDeclEnd:]) - - return sb.String() -} - func (e *EmulatorBackend) StandardLibraryHandler() stdlib.StandardLibraryHandler { return e.stdlibHandler } @@ -709,6 +622,147 @@ func (e *EmulatorBackend) LoadSnapshot(name string) error { return e.blockchain.LoadSnapshot(name) } +// Creates the number of predefined accounts that will be used +// for deploying the contracts under testing. +func (e *EmulatorBackend) bootstrapAccounts() { + for i := 0; i < initialAccountsNumber; i++ { + _, err := e.CreateAccount() + if err != nil { + panic(err) + } + } +} + +func (e *EmulatorBackend) newTransaction(code string, authorizers []common.Address) *sdk.Transaction { + serviceKey := e.blockchain.ServiceKey() + + sequenceNumber := serviceKey.SequenceNumber + e.blockOffset + + tx := sdk.NewTransaction(). + SetScript([]byte(code)). + SetProposalKey(serviceKey.Address, serviceKey.Index, sequenceNumber). + SetPayer(serviceKey.Address) + + for _, authorizer := range authorizers { + tx = tx.AddAuthorizer(sdk.Address(authorizer)) + } + + return tx +} + +func (e *EmulatorBackend) signTransaction( + tx *sdk.Transaction, + signerAccounts []*stdlib.Account, +) error { + + // Sign transaction with each signer + // Note: Following logic is borrowed from the flow-ft. + + for i := len(signerAccounts) - 1; i >= 0; i-- { + signerAccount := signerAccounts[i] + + publicKey := signerAccount.PublicKey.PublicKey + accountKeys := e.accountKeys[signerAccount.Address] + keyInfo := accountKeys[string(publicKey)] + + err := tx.SignPayload(sdk.Address(signerAccount.Address), 0, keyInfo.signer) + if err != nil { + return err + } + } + + serviceKey := e.blockchain.ServiceKey() + serviceSigner, err := serviceKey.Signer() + if err != nil { + return err + } + + err = tx.SignEnvelope(serviceKey.Address, 0, serviceSigner) + if err != nil { + return err + } + + return nil +} + +func (e *EmulatorBackend) replaceImports(code string) string { + program, err := parser.ParseProgram(nil, []byte(code), parser.Config{}) + if err != nil { + panic(err) + } + + sb := strings.Builder{} + importDeclEnd := 0 + for _, importDeclaration := range program.ImportDeclarations() { + prevImportDeclEnd := importDeclEnd + importDeclEnd = importDeclaration.EndPos.Offset + 1 + + location, ok := importDeclaration.Location.(common.StringLocation) + if !ok { + // keep the import statement it as-is + sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) + continue + } + + var address common.Address + if len(importDeclaration.Identifiers) > 0 { + address, ok = e.contracts[importDeclaration.Identifiers[0].Identifier] + if !ok { + // keep import statement it as-is + sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) + continue + } + } else { + address = e.contracts[location.String()] + } + + var importStr string + if strings.Contains(importDeclaration.String(), "from") { + importStr = fmt.Sprintf("0x%s", address) + } else { + // Imports of the form `import "FungibleToken"` should be + // expanded to `import FungibleToken from 0xee82856bf20e2aa6` + importStr = fmt.Sprintf("%s from 0x%s", location, address) + } + + locationStart := importDeclaration.LocationPos.Offset + + sb.WriteString(code[prevImportDeclEnd:locationStart]) + sb.WriteString(importStr) + } + + sb.WriteString(code[importDeclEnd:]) + + return sb.String() +} + +// newBlockchain returns an emulator blockchain for testing. +func newBlockchain( + hook *logCollectionHook, + opts ...emulator.Option, +) *emulator.Blockchain { + output := zerolog.ConsoleWriter{Out: os.Stdout} + logger := zerolog.New(output).With().Timestamp(). + Logger().Hook(hook).Level(zerolog.InfoLevel) + + b, err := emulator.New( + append( + []emulator.Option{ + emulator.WithStorageLimitEnabled(false), + emulator.WithServerLogger(logger), + emulator.Contracts(commonContracts), + emulator.WithChainID(chain.ChainID()), + }, + opts..., + )..., + ) + if err != nil { + panic(err) + } + + return b +} + // excludeCommonLocations excludes the common contracts from appearing // in the coverage report, as they skew the coverage metrics. func excludeCommonLocations(coverageReport *runtime.CoverageReport) { @@ -724,27 +778,3 @@ func excludeCommonLocations(coverageReport *runtime.CoverageReport) { coverageReport.ExcludeLocation(location) } } - -// baseConfiguration returns an *stdlib.Configuration with contract to -// address mappings for system/common contracts. -func baseConfiguration() *stdlib.Configuration { - addresses := make(map[string]common.Address, 0) - serviceAddress := common.Address(chain.ServiceAddress()) - addresses["NonFungibleToken"] = serviceAddress - addresses["MetadataViews"] = serviceAddress - addresses["ViewResolver"] = serviceAddress - for _, addressLocation := range systemContracts { - contract := addressLocation.Name - address := common.Address(addressLocation.Address) - addresses[contract] = address - } - for _, contractDescription := range commonContracts { - contract := contractDescription.Name - address := common.Address(contractDescription.Address) - addresses[contract] = address - } - - return &stdlib.Configuration{ - Addresses: addresses, - } -} diff --git a/test/test_framework_provider.go b/test/test_framework_provider.go index 85378908..5091e4fe 100644 --- a/test/test_framework_provider.go +++ b/test/test_framework_provider.go @@ -34,6 +34,8 @@ type TestFrameworkProvider struct { stdlibHandler stdlib.StandardLibraryHandler coverageReport *runtime.CoverageReport + + EmulatorBackend *EmulatorBackend } func (tf *TestFrameworkProvider) ReadFile(path string) (string, error) { @@ -61,11 +63,7 @@ func (tf *TestFrameworkProvider) ReadFile(path string) (string, error) { } func (tf *TestFrameworkProvider) NewEmulatorBackend() stdlib.Blockchain { - return NewEmulatorBackend( - tf.fileResolver, - tf.stdlibHandler, - tf.coverageReport, - ) + return tf.EmulatorBackend } func NewTestFrameworkProvider( @@ -73,9 +71,16 @@ func NewTestFrameworkProvider( stdlibHandler stdlib.StandardLibraryHandler, coverageReport *runtime.CoverageReport, ) stdlib.TestFramework { - return &TestFrameworkProvider{ + provider := &TestFrameworkProvider{ fileResolver: fileResolver, stdlibHandler: stdlibHandler, coverageReport: coverageReport, } + provider.EmulatorBackend = NewEmulatorBackend( + fileResolver, + stdlibHandler, + coverageReport, + ) + + return provider } diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 149043b1..6ca76ebe 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -144,8 +144,7 @@ func TestExecuteScript(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeScript( + let result = Test.executeScript( "pub fun main(): Int { return 2 + 3 }", [] ) @@ -168,8 +167,7 @@ func TestExecuteScript(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeScript( + let result = Test.executeScript( "pub fun main(a: Int, b: Int): Int { return a + b }", [2, 3] ) @@ -188,14 +186,13 @@ func TestExecuteScript(t *testing.T) { t.Run("non-empty array returns", func(t *testing.T) { t.Parallel() - const code = `pub fun main(): [UInt64] { return [1, 2, 3]}` + const code = `pub fun main(): [UInt64] { return [1, 2, 3] }` testScript := fmt.Sprintf(` import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeScript("%s", []) + let result = Test.executeScript("%s", []) Test.expect(result, Test.beSucceeded()) @@ -203,8 +200,7 @@ func TestExecuteScript(t *testing.T) { let resultArray = result.returnValue! as! [UInt64] Test.assertEqual(expected, resultArray) } - `, code, - ) + `, code) runner := NewTestRunner() result, err := runner.RunTest(testScript, "test") @@ -221,8 +217,7 @@ func TestExecuteScript(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeScript("%s", []) + let result = Test.executeScript("%s", []) Test.expect(result, Test.beSucceeded()) @@ -230,8 +225,7 @@ func TestExecuteScript(t *testing.T) { let resultArray = result.returnValue! as! [UInt64] Test.assertEqual(expected, resultArray) } - `, code, - ) + `, code) runner := NewTestRunner() result, err := runner.RunTest(testScript, "test") @@ -242,14 +236,13 @@ func TestExecuteScript(t *testing.T) { t.Run("non-empty dictionary returns", func(t *testing.T) { t.Parallel() - const code = `pub fun main(): {String: Int} { return {\"foo\": 5, \"bar\": 10}}` + const code = `pub fun main(): {String: Int} { return {\"foo\": 5, \"bar\": 10} }` testScript := fmt.Sprintf(` import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeScript("%s", []) + let result = Test.executeScript("%s", []) Test.expect(result, Test.beSucceeded()) @@ -257,8 +250,7 @@ func TestExecuteScript(t *testing.T) { let resultDict = result.returnValue! as! {String: Int} Test.assertEqual(expected, resultDict) } - `, code, - ) + `, code) runner := NewTestRunner() result, err := runner.RunTest(testScript, "test") @@ -275,8 +267,7 @@ func TestExecuteScript(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeScript("%s", []) + let result = Test.executeScript("%s", []) Test.expect(result, Test.beSucceeded()) @@ -284,8 +275,7 @@ func TestExecuteScript(t *testing.T) { let resultDict = result.returnValue! as! {String: Int} Test.assertEqual(expected, resultDict) } - `, code, - ) + `, code) runner := NewTestRunner() result, err := runner.RunTest(testScript, "test") @@ -297,16 +287,25 @@ func TestExecuteScript(t *testing.T) { func TestImportContract(t *testing.T) { t.Parallel() - t.Run("init no params", func(t *testing.T) { + t.Run("contract with no init params", func(t *testing.T) { t.Parallel() const code = ` import Test - import FooContract from "./FooContract" + import "FooContract" + + pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "./FooContract", + arguments: [] + ) + + Test.expect(err, Test.beNil()) + } pub fun test() { - let foo = FooContract() - Test.assertEqual("hello from Foo", foo.sayHello()) + Test.assertEqual("hello from Foo", FooContract.sayHello()) } ` @@ -320,27 +319,63 @@ func TestImportContract(t *testing.T) { } ` + fileResolver := func(path string) (string, error) { + switch path { + case "./FooContract": + return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + importResolver := func(location common.Location) (string, error) { - return fooContract, nil + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "FooContract" { + return fooContract, nil + } + } + + return "", fmt.Errorf("cannot find import location: %s", location.ID()) } - runner := NewTestRunner().WithImportResolver(importResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) require.NoError(t, result.Error) }) - t.Run("init with params", func(t *testing.T) { + t.Run("contract with init params", func(t *testing.T) { t.Parallel() const code = ` import Test import FooContract from "./FooContract" + pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "./FooContract", + arguments: ["hello from Foo"] + ) + + Test.expect(err, Test.beNil()) + } + pub fun test() { - let foo = FooContract(greeting: "hello from Foo") - Test.assertEqual("hello from Foo", foo.sayHello()) + Test.assertEqual("hello from Foo", FooContract.sayHello()) } ` @@ -359,11 +394,38 @@ func TestImportContract(t *testing.T) { } ` + fileResolver := func(path string) (string, error) { + switch path { + case "./FooContract": + return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + importResolver := func(location common.Location) (string, error) { - return fooContract, nil + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "./FooContract" { + return fooContract, nil + } + } + + return "", fmt.Errorf("cannot find import location: %s", location.ID()) } - runner := NewTestRunner().WithImportResolver(importResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) @@ -377,12 +439,12 @@ func TestImportContract(t *testing.T) { import FooContract from "./FooContract" pub fun test() { - let foo = FooContract() + let message = FooContract.sayHello() } ` importResolver := func(location common.Location) (string, error) { - return "", errors.New("cannot load file") + return "", errors.New("cannot import location") } runner := NewTestRunner().WithImportResolver(importResolver) @@ -394,7 +456,7 @@ func TestImportContract(t *testing.T) { importedProgramError := &sema.ImportedProgramError{} assert.ErrorAs(t, errs[0], &importedProgramError) - assert.Contains(t, importedProgramError.Err.Error(), "cannot load file") + assert.Contains(t, importedProgramError.Err.Error(), "cannot import location") assert.IsType(t, &sema.NotDeclaredError{}, errs[1]) }) @@ -406,7 +468,7 @@ func TestImportContract(t *testing.T) { import FooContract from "./FooContract" pub fun test() { - let foo = FooContract() + let message = FooContract.sayHello() } ` @@ -426,15 +488,32 @@ func TestImportContract(t *testing.T) { t.Run("nested imports", func(t *testing.T) { t.Parallel() - testLocation := common.AddressLocation{ - Address: common.MustBytesToAddress([]byte{0x1}), - Name: "BarContract", - } - const code = ` + import Test + import BarContract from "./BarContract" import FooContract from "./FooContract" - pub fun test() {} + pub let account = Test.getAccount(0x0000000000000005) + + pub fun setup() { + var err = Test.deployContract( + name: "BarContract", + path: "./BarContract", + arguments: [] + ) + Test.expect(err, Test.beNil()) + + err = Test.deployContract( + name: "FooContract", + path: "./FooContract", + arguments: [] + ) + Test.expect(err, Test.beNil()) + } + + pub fun test() { + Test.assertEqual(1, 1) + } ` const fooContract = ` @@ -453,12 +532,18 @@ func TestImportContract(t *testing.T) { importResolver := func(location common.Location) (string, error) { switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + if location.Name == "BarContract" { + return barContract, nil + } case common.StringLocation: if location == "./FooContract" { return fooContract, nil } - case common.AddressLocation: - if location == testLocation { + if location == "./BarContract" { return barContract, nil } } @@ -466,28 +551,39 @@ func TestImportContract(t *testing.T) { return "", fmt.Errorf("unsupported import %s", location) } - runner := NewTestRunner().WithImportResolver(importResolver) + fileResolver := func(path string) (string, error) { + switch path { + case "./FooContract": + return fooContract, nil + case "./BarContract": + return barContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + contracts := map[string]common.Address{ + "BarContract": {0, 0, 0, 0, 0, 0, 0, 5}, + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithContracts(contracts). + WithFileResolver(fileResolver) _, err := runner.RunTest(code, "test") - require.Error(t, err) - assert.Contains(t, err.Error(), "nested imports are not supported") + require.NoError(t, err) }) } func TestImportBuiltinContracts(t *testing.T) { t.Parallel() - testCode := ` + const testCode = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() - - pub fun setup() { - blockchain.useConfiguration(Test.Configuration({ - "FooContract": account.address - })) - } + pub let account = Test.createAccount() pub fun testSetupExampleNFTCollection() { let code = Test.readFile("../transactions/setup_example_nft_collection.cdc") @@ -498,20 +594,20 @@ func TestImportBuiltinContracts(t *testing.T) { arguments: [] ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } pub fun testGetIntegerTrait() { let script = Test.readFile("../scripts/import_common_contracts.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual(true, result.returnValue! as! Bool) } ` - transactionCode := ` + const transactionCode = ` import "NonFungibleToken" import "ExampleNFT" import "MetadataViews" @@ -539,7 +635,7 @@ func TestImportBuiltinContracts(t *testing.T) { } ` - scriptCode := ` + const scriptCode = ` import "FungibleToken" import "FlowToken" import "NonFungibleToken" @@ -561,7 +657,7 @@ func TestImportBuiltinContracts(t *testing.T) { case "../scripts/import_common_contracts.cdc": return scriptCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } @@ -625,11 +721,20 @@ func TestUsingEnv(t *testing.T) { const code = ` import Test - import FooContract from "./FooContract" + import "FooContract" + + pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "./FooContract", + arguments: [] + ) + + Test.expect(err, Test.beNil()) + } pub fun test() { - let foo = FooContract() - Test.assertEqual(0.0, foo.getBalance()) + Test.assertEqual(0.0, FooContract.getBalance()) } ` @@ -644,11 +749,38 @@ func TestUsingEnv(t *testing.T) { } ` + fileResolver := func(path string) (string, error) { + switch path { + case "./FooContract": + return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + importResolver := func(location common.Location) (string, error) { - return fooContract, nil + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "FooContract" { + return fooContract, nil + } + } + + return "", fmt.Errorf("cannot find import location: %s", location.ID()) } - runner := NewTestRunner().WithImportResolver(importResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) @@ -662,8 +794,7 @@ func TestUsingEnv(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() // just checking the invocation of verify function Test.assert(!account.publicKey.verify( @@ -688,12 +819,11 @@ func TestUsingEnv(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) @@ -743,12 +873,11 @@ func TestCreateAccount(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let typ = CompositeType("flow.AccountCreated")! - let events = blockchain.eventsOfType(typ) - Test.assertEqual(1, events.length) + let events = Test.eventsOfType(typ) + Test.expect(events.length, Test.beGreaterThan(1)) } ` @@ -762,6 +891,45 @@ func TestCreateAccount(t *testing.T) { require.NoError(t, result.Error) } +func TestGetAccount(t *testing.T) { + t.Parallel() + + const code = ` + import Test + + pub fun testMissingAccount() { + let account = Test.getAccount(0x0000000000000095) + + Test.assertEqual(0x0000000000000005 as Address, account.address) + } + + pub fun testExistingAccount() { + let admin = Test.createAccount() + let account = Test.getAccount(admin.address) + + Test.assertEqual(account.address, admin.address) + Test.assertEqual(account.publicKey.publicKey, admin.publicKey.publicKey) + } + ` + + importResolver := func(location common.Location) (string, error) { + return "", nil + } + + runner := NewTestRunner().WithImportResolver(importResolver) + result, err := runner.RunTest(code, "testMissingAccount") + require.NoError(t, err) + require.ErrorContains( + t, + result.Error, + "account with address: 0x0000000000000095 was not found", + ) + + result, err = runner.RunTest(code, "testExistingAccount") + require.NoError(t, err) + assert.NoError(t, result.Error) +} + func TestExecutingTransactions(t *testing.T) { t.Parallel() @@ -772,8 +940,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(false) } }", @@ -782,7 +949,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - blockchain.addTransaction(tx) + Test.addTransaction(tx) } ` @@ -799,8 +966,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(true) } }", @@ -809,9 +975,9 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - blockchain.addTransaction(tx) + Test.addTransaction(tx) - let result = blockchain.executeNextTransaction()! + let result = Test.executeNextTransaction()! Test.expect(result, Test.beSucceeded()) } ` @@ -829,8 +995,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { prepare(acct: AuthAccount) {} execute{ assert(true) } }", @@ -839,9 +1004,9 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - blockchain.addTransaction(tx) + Test.addTransaction(tx) - let result = blockchain.executeNextTransaction()! + let result = Test.executeNextTransaction()! Test.expect(result, Test.beSucceeded()) } ` @@ -859,8 +1024,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(false) } }", @@ -869,9 +1033,9 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - blockchain.addTransaction(tx) + Test.addTransaction(tx) - let result = blockchain.executeNextTransaction()! + let result = Test.executeNextTransaction()! Test.expect(result, Test.beFailed()) } ` @@ -889,8 +1053,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let result = blockchain.executeNextTransaction() + let result = Test.executeNextTransaction() Test.expect(result, Test.beNil()) } ` @@ -908,8 +1071,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - blockchain.commitBlock() + Test.commitBlock() } ` @@ -926,8 +1088,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(false) } }", @@ -936,9 +1097,9 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - blockchain.addTransaction(tx) + Test.addTransaction(tx) - blockchain.commitBlock() + Test.commitBlock() } ` @@ -957,8 +1118,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(false) } }", @@ -968,14 +1128,14 @@ func TestExecutingTransactions(t *testing.T) { ) // Add two transactions - blockchain.addTransaction(tx) - blockchain.addTransaction(tx) + Test.addTransaction(tx) + Test.addTransaction(tx) // But execute only one - blockchain.executeNextTransaction() + Test.executeNextTransaction() // Then try to commit - blockchain.commitBlock() + Test.commitBlock() } ` @@ -994,9 +1154,8 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - blockchain.commitBlock() - blockchain.commitBlock() + Test.commitBlock() + Test.commitBlock() } ` @@ -1013,8 +1172,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(true) } }", @@ -1023,7 +1181,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } ` @@ -1041,8 +1199,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction(a: Int, b: Int) { execute{ assert(a == b) } }", @@ -1051,7 +1208,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [4, 4], ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } ` @@ -1069,9 +1226,8 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account1 = blockchain.createAccount() - let account2 = blockchain.createAccount() + let account1 = Test.createAccount() + let account2 = Test.createAccount() let tx = Test.Transaction( code: "transaction() { prepare(acct1: AuthAccount, acct2: AuthAccount) {} }", @@ -1080,7 +1236,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } ` @@ -1098,8 +1254,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction { execute{ assert(fail) } }", @@ -1108,7 +1263,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beFailed()) } ` @@ -1126,8 +1281,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx1 = Test.Transaction( code: "transaction { execute{ assert(true) } }", @@ -1150,7 +1304,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - let firstResults = blockchain.executeTransactions([tx1, tx2, tx3]) + let firstResults = Test.executeTransactions([tx1, tx2, tx3]) Test.assertEqual(3, firstResults.length) Test.expect(firstResults[0], Test.beSucceeded()) @@ -1159,7 +1313,7 @@ func TestExecutingTransactions(t *testing.T) { // Execute them again: To verify the proper increment/reset of sequence numbers. - let secondResults = blockchain.executeTransactions([tx1, tx2, tx3]) + let secondResults = Test.executeTransactions([tx1, tx2, tx3]) Test.assertEqual(3, secondResults.length) Test.expect(secondResults[0], Test.beSucceeded()) @@ -1181,10 +1335,9 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() - let result = blockchain.executeTransactions([]) + let result = Test.executeTransactions([]) Test.assertEqual(0, result.length) } ` @@ -1202,8 +1355,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx1 = Test.Transaction( code: "transaction { execute{ assert(true) } }", @@ -1212,7 +1364,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - blockchain.addTransaction(tx1) + Test.addTransaction(tx1) let tx2 = Test.Transaction( code: "transaction { execute{ assert(true) } }", @@ -1221,7 +1373,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [], ) - let result = blockchain.executeTransaction(tx2) + let result = Test.executeTransaction(tx2) Test.expect(result, Test.beSucceeded()) } ` @@ -1241,8 +1393,7 @@ func TestExecutingTransactions(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx = Test.Transaction( code: "transaction(a: [Int]) { execute{ assert(a[0] == a[1]) } }", @@ -1251,7 +1402,7 @@ func TestExecutingTransactions(t *testing.T) { arguments: [[4, 4]], ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } ` @@ -1271,15 +1422,13 @@ func TestSetupAndTearDown(t *testing.T) { const code = ` import Test - pub(set) var setupRan = false pub fun setup() { - Test.assert(!setupRan) - setupRan = true + log("setup is running!") } pub fun testFunc() { - Test.assert(setupRan) + Test.assert(true) } ` @@ -1291,6 +1440,8 @@ func TestSetupAndTearDown(t *testing.T) { result := results[0] assert.Equal(t, result.TestName, "testFunc") require.NoError(t, result.Error) + + assert.ElementsMatch(t, []string{"setup is running!"}, runner.Logs()) }) t.Run("setup failed", func(t *testing.T) { @@ -1320,14 +1471,12 @@ func TestSetupAndTearDown(t *testing.T) { const code = ` import Test - pub(set) var tearDownRan = false - pub fun testFunc() { - Test.assert(!tearDownRan) + Test.assert(true) } pub fun tearDown() { - Test.assert(true) + log("tearDown is running!") } ` @@ -1339,13 +1488,15 @@ func TestSetupAndTearDown(t *testing.T) { result := results[0] assert.Equal(t, result.TestName, "testFunc") require.NoError(t, result.Error) + + assert.ElementsMatch(t, []string{"tearDown is running!"}, runner.Logs()) }) t.Run("teardown failed", func(t *testing.T) { t.Parallel() const code = ` - import Test + import Test pub(set) var tearDownRan = false @@ -1378,7 +1529,7 @@ func TestBeforeAndAfterEach(t *testing.T) { t.Run("beforeEach", func(t *testing.T) { t.Parallel() - code := ` + const code = ` import Test pub(set) var counter = 0 @@ -1410,7 +1561,7 @@ func TestBeforeAndAfterEach(t *testing.T) { t.Run("beforeEach failed", func(t *testing.T) { t.Parallel() - code := ` + const code = ` import Test pub fun beforeEach() { @@ -1431,7 +1582,7 @@ func TestBeforeAndAfterEach(t *testing.T) { t.Run("afterEach", func(t *testing.T) { t.Parallel() - code := ` + const code = ` import Test pub(set) var counter = 2 @@ -1467,7 +1618,7 @@ func TestBeforeAndAfterEach(t *testing.T) { t.Run("afterEach failed", func(t *testing.T) { t.Parallel() - code := ` + const code = ` import Test pub(set) var tearDownRan = false @@ -1546,12 +1697,11 @@ func TestLoadingProgramsFromLocalFile(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual(5, result.returnValue! as! Int) @@ -1588,12 +1738,11 @@ func TestLoadingProgramsFromLocalFile(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual(5, result.returnValue! as! Int) @@ -1625,8 +1774,7 @@ func TestLoadingProgramsFromLocalFile(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let script = Test.readFile("./sample/script.cdc") } @@ -1647,28 +1795,41 @@ func TestDeployingContracts(t *testing.T) { t.Run("no args", func(t *testing.T) { t.Parallel() + const contract = ` + pub contract Foo { + init() {} + + pub fun sayHello(): String { + return "hello from Foo" + } + } + ` + + const script = ` + import Foo from "Foo.cdc" + + pub fun main(): String { + return Foo.sayHello() + } + ` + const code = ` import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() - - let contractCode = "pub contract Foo{ init(){} pub fun sayHello(): String { return \"hello from Foo\"} }" + let account = Test.getAccount(0x0000000000000005) - let err = blockchain.deployContract( + let err = Test.deployContract( name: "Foo", - code: contractCode, - account: account, + path: "Foo.cdc", arguments: [], ) Test.expect(err, Test.beNil()) - var script = "import Foo from ".concat(account.address.toString()).concat("\n") - script = script.concat("pub fun main(): String { return Foo.sayHello() }") + let script = Test.readFile("say_hello.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) @@ -1677,7 +1838,24 @@ func TestDeployingContracts(t *testing.T) { } ` - runner := NewTestRunner() + fileResolver := func(path string) (string, error) { + switch path { + case "Foo.cdc": + return contract, nil + case "say_hello.cdc": + return script, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) require.NoError(t, result.Error) @@ -1686,28 +1864,45 @@ func TestDeployingContracts(t *testing.T) { t.Run("with args", func(t *testing.T) { t.Parallel() + const contract = ` + pub contract Foo { + pub let msg: String + + init(_ msg: String) { + self.msg = msg + } + + pub fun sayHello(): String { + return self.msg + } + } + ` + + const script = ` + import Foo from "Foo.cdc" + + pub fun main(): String { + return Foo.sayHello() + } + ` + const code = ` import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.getAccount(0x0000000000000005) - let contractCode = "pub contract Foo{ pub let msg: String; init(_ msg: String){ self.msg = msg } pub fun sayHello(): String { return self.msg } }" - - let err = blockchain.deployContract( + let err = Test.deployContract( name: "Foo", - code: contractCode, - account: account, + path: "Foo.cdc", arguments: ["hello from args"], ) Test.expect(err, Test.beNil()) - var script = "import Foo from ".concat(account.address.toString()).concat("\n") - script = script.concat("pub fun main(): String { return Foo.sayHello() }") + let script = Test.readFile("say_hello.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) @@ -1716,7 +1911,24 @@ func TestDeployingContracts(t *testing.T) { } ` - runner := NewTestRunner() + fileResolver := func(path string) (string, error) { + switch path { + case "Foo.cdc": + return contract, nil + case "say_hello.cdc": + return script, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) require.NoError(t, result.Error) @@ -1729,19 +1941,23 @@ func TestErrors(t *testing.T) { t.Run("contract deployment error", func(t *testing.T) { t.Parallel() + const contract = ` + pub contract Foo { + init() {} + + pub fun sayHello() { + return 0 + } + } + ` + const code = ` import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() - - let contractCode = "pub contract Foo{ init(){} pub fun sayHello() { return 0 } }" - - let err = blockchain.deployContract( + let err = Test.deployContract( name: "Foo", - code: contractCode, - account: account, + path: "Foo.cdc", arguments: [], ) @@ -1751,7 +1967,22 @@ func TestErrors(t *testing.T) { } ` - runner := NewTestRunner() + fileResolver := func(path string) (string, error) { + switch path { + case "Foo.cdc": + return contract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) require.Error(t, result.Error) @@ -1765,11 +1996,8 @@ func TestErrors(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() - let script = "import Foo from 0x01; pub fun main() {}" - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) if result.status == Test.ResultStatus.failed { panic(result.error!.message) @@ -1795,8 +2023,7 @@ func TestErrors(t *testing.T) { import Test pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let account = blockchain.createAccount() + let account = Test.createAccount() let tx2 = Test.Transaction( code: "transaction { execute{ panic(\"some error\") } }", @@ -1805,7 +2032,7 @@ func TestErrors(t *testing.T) { arguments: [], ) - let result = blockchain.executeTransaction(tx2)! + let result = Test.executeTransaction(tx2)! Test.assertError(result, errorMessage: "some error") if result.status == Test.ResultStatus.failed { @@ -2497,44 +2724,34 @@ func TestReplacingImports(t *testing.T) { const code = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { // Deploy the contract - let contractCode = Test.readFile("./sample/contract.cdc") - - let err = blockchain.deployContract( + let err = Test.deployContract( name: "Foo", - code: contractCode, - account: account, + path: "./sample/contract.cdc", arguments: [], ) Test.expect(err, Test.beNil()) - - // Set the configurations to use the address of the deployed contract. - - blockchain.useConfiguration(Test.Configuration({ - "./FooContract": account.address - })) - } + } pub fun test() { let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual("hello from Foo", result.returnValue! as! String) } - ` + ` const contractCode = ` - pub contract Foo{ + pub contract Foo { init() {} pub fun sayHello(): String { - return "hello from Foo" + return "hello from Foo" } } ` @@ -2554,11 +2771,17 @@ func TestReplacingImports(t *testing.T) { case "./sample/contract.cdc": return contractCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } - runner := NewTestRunner().WithFileResolver(fileResolver) + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) @@ -2571,31 +2794,21 @@ func TestReplacingImports(t *testing.T) { const code = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - let contractCode = Test.readFile("./sample/contract.cdc") - - let err = blockchain.deployContract( + let err = Test.deployContract( name: "Foo", - code: contractCode, - account: account, + path: "./sample/contract.cdc", arguments: [], ) Test.expect(err, Test.beNil()) - - // Address locations are not replaceable! - - blockchain.useConfiguration(Test.Configuration({ - "0x01": account.address - })) } pub fun test() { let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beFailed()) if result.status == Test.ResultStatus.failed { @@ -2606,11 +2819,11 @@ func TestReplacingImports(t *testing.T) { ` const contractCode = ` - pub contract Foo{ - init(){} + pub contract Foo { + init() {} pub fun sayHello(): String { - return "hello from Foo" + return "hello from Foo" } } ` @@ -2630,11 +2843,17 @@ func TestReplacingImports(t *testing.T) { case "./sample/contract.cdc": return contractCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } - runner := NewTestRunner().WithFileResolver(fileResolver) + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) @@ -2652,16 +2871,12 @@ func TestReplacingImports(t *testing.T) { const code = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.createAccount() pub fun setup() { - let contractCode = Test.readFile("./sample/contract.cdc") - - let err = blockchain.deployContract( + let err = Test.deployContract( name: "Foo", - code: contractCode, - account: account, + path: "./sample/contract.cdc", arguments: [], ) @@ -2672,9 +2887,9 @@ func TestReplacingImports(t *testing.T) { pub fun test() { let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) - Test.expect(result, Test.beFailed()) + Test.expect(result, Test.beSucceeded()) if result.status == Test.ResultStatus.failed { panic(result.error!.message) } @@ -2683,11 +2898,11 @@ func TestReplacingImports(t *testing.T) { ` const contractCode = ` - pub contract Foo{ + pub contract Foo { init() {} pub fun sayHello(): String { - return "hello from Foo" + return "hello from Foo" } } ` @@ -2707,20 +2922,21 @@ func TestReplacingImports(t *testing.T) { case "./sample/contract.cdc": return contractCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } - runner := NewTestRunner().WithFileResolver(fileResolver) + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) - require.Error(t, result.Error) - assert.Contains( - t, - result.Error.Error(), - "expecting an AddressLocation, but other location types are passed", - ) + require.NoError(t, result.Error) }) t.Run("config with missing imports", func(t *testing.T) { @@ -2729,19 +2945,21 @@ func TestReplacingImports(t *testing.T) { const code = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - // Configurations provided, but some imports are missing. - blockchain.useConfiguration(Test.Configuration({ - "./FooContract": account.address - })) + let err = Test.deployContract( + name: "Foo", + path: "./FooContract", + arguments: [], + ) + + Test.expect(err, Test.beNil()) } pub fun test() { let script = Test.readFile("./sample/script.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beFailed()) if result.status == Test.ResultStatus.failed { @@ -2753,23 +2971,41 @@ func TestReplacingImports(t *testing.T) { const scriptCode = ` import Foo from "./FooContract" - import Foo from "./BarContract" // This is missing in configs + import Bar from "./BarContract" // This is missing in configs pub fun main(): String { return Foo.sayHello() } ` + const contractCode = ` + pub contract Foo { + init() {} + + pub fun sayHello(): String { + return "hello from Foo" + } + } + ` + fileResolver := func(path string) (string, error) { switch path { case "./sample/script.cdc": return scriptCode, nil + case "./FooContract": + return contractCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } - runner := NewTestRunner().WithFileResolver(fileResolver) + contracts := map[string]common.Address{ + "Foo": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) result, err := runner.RunTest(code, "test") require.NoError(t, err) @@ -2786,26 +3022,26 @@ func TestReplaceImports(t *testing.T) { t.Parallel() emulatorBackend := NewEmulatorBackend(nil, nil, nil) - emulatorBackend.UseConfiguration(&stdlib.Configuration{ - Addresses: map[string]common.Address{ - "./sample/contract1.cdc": {0x1}, - "./sample/contract2.cdc": {0x2}, - "./sample/contract3.cdc": {0x3}, - }, - }) + emulatorBackend.contracts = map[string]common.Address{ + "C1": {0, 0, 0, 0, 0, 0, 0, 1}, + "C2": {0, 0, 0, 0, 0, 0, 0, 2}, + "C3": {0, 0, 0, 0, 0, 0, 0, 1}, + } const code = ` import C1 from "./sample/contract1.cdc" - import C2 from "./sample/contract2.cdc" - import C3 from "./sample/contract3.cdc" + import C2 from "C2" + import "C3" + import C4 from 0x0000000000000009 pub fun main() {} ` const expected = ` - import C1 from 0x0100000000000000 - import C2 from 0x0200000000000000 - import C3 from 0x0300000000000000 + import C1 from 0x0000000000000001 + import C2 from 0x0000000000000002 + import C3 from 0x0000000000000001 + import C4 from 0x0000000000000009 pub fun main() {} ` @@ -2822,15 +3058,12 @@ func TestGetAccountFlowBalance(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun testGetFlowBalance() { // Arrange - let account = blockchain.serviceAccount() + let account = Test.serviceAccount() // Act - let balance = helpers.getFlowBalance(for: account) + let balance = getFlowBalance(for: account) // Assert Test.assertEqual(1000000000.0, balance) @@ -2851,19 +3084,16 @@ func TestGetCurrentBlockHeight(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun testGetCurrentBlockHeight() { // Act - let height = helpers.getCurrentBlockHeight() + let height = getCurrentBlockHeight() // Assert Test.expect(height, Test.beGreaterThan(1 as UInt64)) // Act - blockchain.commitBlock() - let newHeight = helpers.getCurrentBlockHeight() + Test.commitBlock() + let newHeight = getCurrentBlockHeight() // Assert Test.assertEqual(newHeight, height + 1) @@ -2884,18 +3114,15 @@ func TestMintFlow(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun testMintFlow() { // Arrange - let account = blockchain.createAccount() + let account = Test.createAccount() // Act - helpers.mintFlow(to: account, amount: 1500.0) + mintFlow(to: account, amount: 1500.0) // Assert - let balance = helpers.getFlowBalance(for: account) + let balance = getFlowBalance(for: account) Test.assertEqual(1500.0, balance) } ` @@ -2914,25 +3141,22 @@ func TestBurnFlow(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun testBurnFlow() { // Arrange - let account = blockchain.createAccount() + let account = Test.createAccount() // Act - helpers.mintFlow(to: account, amount: 1500.0) + mintFlow(to: account, amount: 1500.0) // Assert - var balance = helpers.getFlowBalance(for: account) + var balance = getFlowBalance(for: account) Test.assertEqual(1500.0, balance) // Act - helpers.burnFlow(from: account, amount: 500.0) + burnFlow(from: account, amount: 500.0) // Assert - balance = helpers.getFlowBalance(for: account) + balance = getFlowBalance(for: account) Test.assertEqual(1000.0, balance) } ` @@ -2968,11 +3192,9 @@ func TestServiceAccount(t *testing.T) { const testCode = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub fun testGetServiceAccount() { // Act - let account = blockchain.serviceAccount() + let account = Test.serviceAccount() // Assert Test.assertEqual(Type
(), account.address.getType()) @@ -2995,15 +3217,12 @@ func TestServiceAccount(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun testGetServiceAccountBalance() { // Arrange - let account = blockchain.serviceAccount() + let account = Test.serviceAccount() // Act - let balance = helpers.getFlowBalance(for: account) + let balance = getFlowBalance(for: account) // Assert Test.assertEqual(1000000000.0, balance) @@ -3011,8 +3230,8 @@ func TestServiceAccount(t *testing.T) { pub fun testTransferFlowTokens() { // Arrange - let account = blockchain.serviceAccount() - let receiver = blockchain.createAccount() + let account = Test.serviceAccount() + let receiver = Test.createAccount() let code = Test.readFile("../transactions/transfer_flow_tokens.cdc") let tx = Test.Transaction( @@ -3023,11 +3242,11 @@ func TestServiceAccount(t *testing.T) { ) // Act - let txResult = blockchain.executeTransaction(tx) + let txResult = Test.executeTransaction(tx) Test.expect(txResult, Test.beSucceeded()) // Assert - let balance = helpers.getFlowBalance(for: receiver) + let balance = getFlowBalance(for: receiver) Test.assertEqual(1500.0, balance) } ` @@ -3058,7 +3277,7 @@ func TestServiceAccount(t *testing.T) { case "../transactions/transfer_flow_tokens.cdc": return transactionCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } @@ -3117,9 +3336,17 @@ func TestCoverageReportForUnitTests(t *testing.T) { const code = ` import Test - import FooContract from "FooContract.cdc" + import FooContract from "../contracts/FooContract.cdc" - pub let foo = FooContract() + pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "../contracts/FooContract.cdc", + arguments: [] + ) + + Test.expect(err, Test.beNil()) + } pub fun testGetIntegerTrait() { // Arrange @@ -3137,7 +3364,7 @@ func TestCoverageReportForUnitTests(t *testing.T) { for input in testInputs.keys { // Act - let result = foo.getIntegerTrait(input) + let result = FooContract.getIntegerTrait(input) // Assert Test.assertEqual(result, testInputs[input]!) @@ -3146,40 +3373,68 @@ func TestCoverageReportForUnitTests(t *testing.T) { pub fun testAddSpecialNumber() { // Act - foo.addSpecialNumber(78557, "Sierpinski") + FooContract.addSpecialNumber(78557, "Sierpinski") // Assert - Test.assertEqual("Sierpinski", foo.getIntegerTrait(78557)) + Test.assertEqual("Sierpinski", FooContract.getIntegerTrait(78557)) } ` - importResolver := func(location common.Location) (string, error) { - if location == common.StringLocation("FooContract.cdc") { + fileResolver := func(path string) (string, error) { + switch path { + case "../contracts/FooContract.cdc": return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) } + } - return "", fmt.Errorf("unsupported import %s", location) + importResolver := func(location common.Location) (string, error) { + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "../contracts/FooContract.cdc" { + return fooContract, nil + } + } + + return "", fmt.Errorf("cannot find import location: %s", location.ID()) + } + + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 9}, } coverageReport := runtime.NewCoverageReport() + coverageReport.WithLocationFilter(func(location common.Location) bool { + _, addressLoc := location.(common.AddressLocation) + _, stringLoc := location.(common.StringLocation) + // We only allow inspection of AddressLocation or StringLocation + return addressLoc || stringLoc + }) runner := NewTestRunner(). + WithFileResolver(fileResolver). WithImportResolver(importResolver). - WithCoverageReport(coverageReport) + WithCoverageReport(coverageReport). + WithContracts(contracts) results, err := runner.RunTests(code) - require.NoError(t, err) + require.NoError(t, err) require.Len(t, results, 2) + for _, result := range results { + assert.NoError(t, result.Error) + } - result1 := results[0] - assert.Equal(t, result1.TestName, "testGetIntegerTrait") - assert.NoError(t, result1.Error) - - result2 := results[1] - assert.Equal(t, result2.TestName, "testAddSpecialNumber") - require.NoError(t, result2.Error) - - location := common.StringLocation("FooContract.cdc") + address, err := common.HexToAddress("0x0000000000000009") + require.NoError(t, err) + location := common.AddressLocation{ + Address: address, + Name: "FooContract", + } coverage := coverageReport.Coverage[location] assert.Equal(t, []int{}, coverage.MissedLines()) @@ -3188,7 +3443,7 @@ func TestCoverageReportForUnitTests(t *testing.T) { assert.EqualValues( t, map[int]int{ - 6: 1, 14: 1, 18: 10, 19: 1, 20: 9, 21: 1, 22: 8, 23: 1, + 6: 2, 14: 1, 18: 10, 19: 1, 20: 9, 21: 1, 22: 8, 23: 1, 24: 7, 25: 1, 26: 6, 27: 1, 30: 5, 31: 4, 34: 1, }, coverage.LineHits, @@ -3197,9 +3452,25 @@ func TestCoverageReportForUnitTests(t *testing.T) { assert.ElementsMatch( t, []string{ - "s.7465737400000000000000000000000000000000000000000000000000000000", - "I.Crypto", + "A.0000000000000001.FlowClusterQC", + "A.0000000000000001.NFTStorefront", + "A.0000000000000002.FungibleToken", + "A.0000000000000001.NodeVersionBeacon", + "A.0000000000000003.FlowToken", + "A.0000000000000001.FlowEpoch", + "A.0000000000000001.FlowIDTableStaking", + "A.0000000000000001.NFTStorefrontV2", + "A.0000000000000001.FlowStakingCollection", + "A.0000000000000001.FlowServiceAccount", + "A.0000000000000001.FlowStorageFees", + "A.0000000000000001.LockedTokens", + "A.0000000000000001.FlowDKG", + "A.0000000000000004.FlowFees", + "A.0000000000000001.ExampleNFT", + "A.0000000000000001.StakingProxy", "I.Test", + "I.Crypto", + "s.7465737400000000000000000000000000000000000000000000000000000000", }, coverageReport.ExcludedLocationIDs(), ) @@ -3283,28 +3554,21 @@ func TestCoverageReportForIntegrationTests(t *testing.T) { const testCode = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000009) pub fun setup() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "FooContract", - code: contractCode, - account: account, + path: "../contracts/FooContract.cdc", arguments: [] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account.address - })) } pub fun testGetIntegerTrait() { let script = Test.readFile("../scripts/get_integer_traits.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assert(result.returnValue! as! Bool) @@ -3319,7 +3583,7 @@ func TestCoverageReportForIntegrationTests(t *testing.T) { arguments: [78557, "Sierpinski"] ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } ` @@ -3349,10 +3613,14 @@ func TestCoverageReportForIntegrationTests(t *testing.T) { case "../transactions/add_special_number.cdc": return transactionCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 9}, + } + coverageReport := runtime.NewCoverageReport() coverageReport.WithLocationFilter(func(location common.Location) bool { _, addressLoc := location.(common.AddressLocation) @@ -3362,7 +3630,8 @@ func TestCoverageReportForIntegrationTests(t *testing.T) { }) runner := NewTestRunner(). WithFileResolver(fileResolver). - WithCoverageReport(coverageReport) + WithCoverageReport(coverageReport). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -3377,7 +3646,7 @@ func TestCoverageReportForIntegrationTests(t *testing.T) { assert.Equal(t, result2.TestName, "testAddSpecialNumber") require.NoError(t, result2.Error) - address, err := common.HexToAddress("0x0000000000000005") + address, err := common.HexToAddress("0x0000000000000009") require.NoError(t, err) location := common.AddressLocation{ Address: address, @@ -3461,15 +3730,21 @@ func TestRetrieveLogsFromUnitTests(t *testing.T) { import Test import FooContract from "FooContract.cdc" - pub let foo = FooContract() - pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "FooContract.cdc", + arguments: [] + ) + + Test.expect(err, Test.beNil()) + log("setup successful") } pub fun testGetIntegerTrait() { // Act - let result = foo.getIntegerTrait(1729) + let result = FooContract.getIntegerTrait(1729) // Assert Test.assertEqual("Harshad", result) @@ -3478,23 +3753,46 @@ func TestRetrieveLogsFromUnitTests(t *testing.T) { pub fun testAddSpecialNumber() { // Act - foo.addSpecialNumber(78557, "Sierpinski") + FooContract.addSpecialNumber(78557, "Sierpinski") // Assert - Test.assertEqual("Sierpinski", foo.getIntegerTrait(78557)) + Test.assertEqual("Sierpinski", FooContract.getIntegerTrait(78557)) log("addSpecialNumber works") } ` - importResolver := func(location common.Location) (string, error) { - if location == common.StringLocation("FooContract.cdc") { + fileResolver := func(path string) (string, error) { + switch path { + case "FooContract.cdc": return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + importResolver := func(location common.Location) (string, error) { + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "FooContract.cdc" { + return fooContract, nil + } } return "", fmt.Errorf("unsupported import %s", location) } - runner := NewTestRunner().WithImportResolver(importResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithFileResolver(fileResolver). + WithContracts(contracts) results, err := runner.RunTests(code) require.NoError(t, err) @@ -3545,11 +3843,19 @@ func TestRetrieveEmptyLogsFromUnitTests(t *testing.T) { import Test import FooContract from "FooContract.cdc" - pub let foo = FooContract() + pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "FooContract.cdc", + arguments: [] + ) + + Test.expect(err, Test.beNil()) + } pub fun testGetIntegerTrait() { - // Act - let result = foo.getIntegerTrait(1729) + // Act + let result = FooContract.getIntegerTrait(1729) // Assert Test.assertEqual("Harshad", result) @@ -3557,22 +3863,45 @@ func TestRetrieveEmptyLogsFromUnitTests(t *testing.T) { pub fun testAddSpecialNumber() { // Act - foo.addSpecialNumber(78557, "Sierpinski") + FooContract.addSpecialNumber(78557, "Sierpinski") // Assert - Test.assertEqual("Sierpinski", foo.getIntegerTrait(78557)) + Test.assertEqual("Sierpinski", FooContract.getIntegerTrait(78557)) } ` - importResolver := func(location common.Location) (string, error) { - if location == common.StringLocation("FooContract.cdc") { + fileResolver := func(path string) (string, error) { + switch path { + case "FooContract.cdc": return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + importResolver := func(location common.Location) (string, error) { + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "FooContract.cdc" { + return fooContract, nil + } } return "", fmt.Errorf("unsupported import %s", location) } - runner := NewTestRunner().WithImportResolver(importResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithFileResolver(fileResolver). + WithContracts(contracts) results, err := runner.RunTests(code) require.NoError(t, err) @@ -3629,28 +3958,21 @@ func TestRetrieveLogsFromIntegrationTests(t *testing.T) { const testCode = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "FooContract", - code: contractCode, - account: account, + path: "../contracts/FooContract.cdc", arguments: [] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account.address - })) } pub fun testGetIntegerTrait() { let script = Test.readFile("../scripts/get_integer_traits.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assert(result.returnValue! as! Bool) @@ -3665,7 +3987,7 @@ func TestRetrieveLogsFromIntegrationTests(t *testing.T) { arguments: [78557, "Sierpinski"] ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } @@ -3676,7 +3998,7 @@ func TestRetrieveLogsFromIntegrationTests(t *testing.T) { "specialNumbers updated", "addSpecialNumber works" ] - Test.assertEqual(expectedLogs, blockchain.logs()) + Test.assertEqual(expectedLogs, Test.logs()) } ` @@ -3706,11 +4028,17 @@ func TestRetrieveLogsFromIntegrationTests(t *testing.T) { case "../transactions/add_special_number.cdc": return transactionCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } - runner := NewTestRunner().WithFileResolver(fileResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -3761,28 +4089,21 @@ func TestRetrieveEmptyLogsFromIntegrationTests(t *testing.T) { const testCode = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "FooContract", - code: contractCode, - account: account, + path: "../contracts/FooContract.cdc", arguments: [] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account.address - })) } pub fun testGetIntegerTrait() { let script = Test.readFile("../scripts/get_integer_traits.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assert(result.returnValue! as! Bool) @@ -3797,12 +4118,12 @@ func TestRetrieveEmptyLogsFromIntegrationTests(t *testing.T) { arguments: [78557, "Sierpinski"] ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } pub fun tearDown() { - Test.assertEqual([] as [String], blockchain.logs() ) + Test.assertEqual([] as [String], Test.logs() ) } ` @@ -3831,11 +4152,17 @@ func TestRetrieveEmptyLogsFromIntegrationTests(t *testing.T) { case "../transactions/add_special_number.cdc": return transactionCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } - runner := NewTestRunner().WithFileResolver(fileResolver) + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -3889,36 +4216,29 @@ func TestGetEventsFromIntegrationTests(t *testing.T) { const testCode = ` import Test - import FooContract from 0x0000000000000005 + import FooContract from "../contracts/FooContract.cdc" - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "FooContract", - code: contractCode, - account: account, + path: "../contracts/FooContract.cdc", arguments: [] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account.address - })) } pub fun testGetIntegerTrait() { let script = Test.readFile("../scripts/get_integer_traits.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assert(result.returnValue! as! Bool) let typ = Type() - let events = blockchain.eventsOfType(typ) + let events = Test.eventsOfType(typ) Test.assertEqual(1, events.length) } @@ -3931,18 +4251,18 @@ func TestGetEventsFromIntegrationTests(t *testing.T) { arguments: [78557, "Sierpinski"] ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) let typ = Type() - let events = blockchain.eventsOfType(typ) + let events = Test.eventsOfType(typ) Test.assertEqual(1, events.length) let event = events[0] as! FooContract.NumberAdded Test.assertEqual(78557, event.n) Test.assertEqual("Sierpinski", event.trait) - let evts = blockchain.events() + let evts = Test.events() Test.expect(evts.length, Test.beGreaterThan(1)) } ` @@ -3972,7 +4292,7 @@ func TestGetEventsFromIntegrationTests(t *testing.T) { case "../transactions/add_special_number.cdc": return transactionCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } @@ -3982,14 +4302,23 @@ func TestGetEventsFromIntegrationTests(t *testing.T) { if location.Name == "FooContract" { return contractCode, nil } + case common.StringLocation: + if location == "../contracts/FooContract.cdc" { + return contractCode, nil + } } return "", fmt.Errorf("cannot find import location: %s", location.ID()) } + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + runner := NewTestRunner(). WithFileResolver(fileResolver). - WithImportResolver(importResolver) + WithImportResolver(importResolver). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -4032,8 +4361,7 @@ func TestImportingHelperFile(t *testing.T) { import Test import "test_helpers.cdc" - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.createAccount() pub fun testRunTransaction() { let tx = createTransaction( @@ -4042,7 +4370,7 @@ func TestImportingHelperFile(t *testing.T) { args: [] ) - let result = blockchain.executeTransaction(tx) + let result = Test.executeTransaction(tx) Test.expect(result, Test.beSucceeded()) } ` @@ -4052,7 +4380,7 @@ func TestImportingHelperFile(t *testing.T) { case "../transactions/add_special_number.cdc": return transactionCode, nil default: - return "", fmt.Errorf("cannot find file: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } @@ -4085,30 +4413,27 @@ func TestBlockchainReset(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun testBlockchainReset() { // Arrange - let account = blockchain.createAccount() - var balance = helpers.getFlowBalance(for: account) + let account = Test.createAccount() + var balance = getFlowBalance(for: account) Test.assertEqual(0.0, balance) - let height = helpers.getCurrentBlockHeight() + let height = getCurrentBlockHeight() - helpers.mintFlow(to: account, amount: 1500.0) + mintFlow(to: account, amount: 1500.0) - balance = helpers.getFlowBalance(for: account) + balance = getFlowBalance(for: account) Test.assertEqual(1500.0, balance) - Test.assertEqual(helpers.getCurrentBlockHeight(), height + 1) + Test.assertEqual(getCurrentBlockHeight(), height + 1) // Act - blockchain.reset(to: height) + Test.reset(to: height) // Assert - balance = helpers.getFlowBalance(for: account) + balance = getFlowBalance(for: account) Test.assertEqual(0.0, balance) - Test.assertEqual(helpers.getCurrentBlockHeight(), height) + Test.assertEqual(getCurrentBlockHeight(), height) } ` @@ -4213,33 +4538,26 @@ func TestBlockchainMoveTime(t *testing.T) { const testCode = ` import Test - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub var lockedAt: UFix64 = 0.0 pub fun setup() { let currentBlockTimestamp = Test.readFile("current_block_timestamp.cdc") - let result = blockchain.executeScript(currentBlockTimestamp, []) + let result = Test.executeScript(currentBlockTimestamp, []) lockedAt = result.returnValue! as! UFix64 - let contractCode = Test.readFile("TimeLocker.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "TimeLocker", - code: contractCode, - account: account, + path: "TimeLocker.cdc", arguments: [lockedAt] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "TimeLocker": account.address - })) } pub fun testIsNotOpen() { let isLockerOpen = Test.readFile("is_locker_open.cdc") - let result = blockchain.executeScript(isLockerOpen, []) + let result = Test.executeScript(isLockerOpen, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual(false, result.returnValue! as! Bool) @@ -4248,25 +4566,25 @@ func TestBlockchainMoveTime(t *testing.T) { pub fun testIsOpen() { // timeDelta is the representation of 20 days, in seconds let timeDelta = Fix64(20 * 24 * 60 * 60) - blockchain.moveTime(by: timeDelta) + Test.moveTime(by: timeDelta) let isLockerOpen = Test.readFile("is_locker_open.cdc") - var result = blockchain.executeScript(isLockerOpen, []) + var result = Test.executeScript(isLockerOpen, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual(false, result.returnValue! as! Bool) // We move time forward by another 20 days - blockchain.moveTime(by: timeDelta) + Test.moveTime(by: timeDelta) - result = blockchain.executeScript(isLockerOpen, []) + result = Test.executeScript(isLockerOpen, []) Test.assertEqual(true, result.returnValue! as! Bool) // We move time backward by 20 days - blockchain.moveTime(by: timeDelta * -1.0) + Test.moveTime(by: timeDelta * -1.0) - result = blockchain.executeScript(isLockerOpen, []) + result = Test.executeScript(isLockerOpen, []) Test.assertEqual(false, result.returnValue! as! Bool) } @@ -4281,17 +4599,33 @@ func TestBlockchainMoveTime(t *testing.T) { case "current_block_timestamp.cdc": return currentBlockTimestamp, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } importResolver := func(location common.Location) (string, error) { - return "", nil + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "TimeLocker" { + return contractCode, nil + } + case common.StringLocation: + if location == "TimeLocker.cdc" { + return contractCode, nil + } + } + + return "", fmt.Errorf("cannot find import location: %s", location.ID()) + } + + contracts := map[string]common.Address{ + "TimeLocker": {0, 0, 0, 0, 0, 0, 0, 5}, } runner := NewTestRunner(). WithFileResolver(fileResolver). - WithImportResolver(importResolver) + WithImportResolver(importResolver). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -4339,44 +4673,6 @@ func TestRandomizedTestExecution(t *testing.T) { assert.Equal(t, expected, resultsStr) } -func TestNewEmulatorBlockchainCleanState(t *testing.T) { - t.Parallel() - - const code = ` - import Test - import BlockchainHelpers - - pub fun test() { - let blockchain = Test.newEmulatorBlockchain() - let helpers = BlockchainHelpers(blockchain: blockchain) - let account = blockchain.createAccount() - - let typ = CompositeType("flow.AccountCreated")! - let events = blockchain.eventsOfType(typ) - Test.assertEqual(1, events.length) - - let blockchain2 = Test.newEmulatorBlockchain() - let helpers2 = BlockchainHelpers(blockchain: blockchain2) - - let events2 = blockchain2.eventsOfType(typ) - Test.assertEqual(0, events2.length) - - Test.assert( - helpers.getCurrentBlockHeight() > helpers2.getCurrentBlockHeight() - ) - } - ` - - importResolver := func(location common.Location) (string, error) { - return "", nil - } - - runner := NewTestRunner().WithImportResolver(importResolver) - result, err := runner.RunTest(code, "test") - require.NoError(t, err) - require.NoError(t, result.Error) -} - func TestReferenceDeployedContractTypes(t *testing.T) { t.Parallel() @@ -4425,29 +4721,22 @@ func TestReferenceDeployedContractTypes(t *testing.T) { const testCode = ` import Test - import FooContract from 0x0000000000000005 + import FooContract from "../contracts/FooContract.cdc" - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "FooContract", - code: contractCode, - account: account, + path: "../contracts/FooContract.cdc", arguments: [] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account.address - })) } pub fun testGetSpecialNumber() { let script = Test.readFile("../scripts/get_special_number.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) let specialNumbers = result.returnValue! as! [FooContract.SpecialNumber] @@ -4468,7 +4757,7 @@ func TestReferenceDeployedContractTypes(t *testing.T) { case "../scripts/get_special_number.cdc": return scriptCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } @@ -4478,14 +4767,23 @@ func TestReferenceDeployedContractTypes(t *testing.T) { if location.Name == "FooContract" { return contractCode, nil } + case common.StringLocation: + if location == "../contracts/FooContract.cdc" { + return contractCode, nil + } } return "", fmt.Errorf("cannot find import location: %s", location.ID()) } + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + runner := NewTestRunner(). WithFileResolver(fileResolver). - WithImportResolver(importResolver) + WithImportResolver(importResolver). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -4548,29 +4846,22 @@ func TestReferenceDeployedContractTypes(t *testing.T) { const testCode = ` import Test - import FooContract from 0x0000000000000005 + import FooContract from "../contracts/FooContract.cdc" - pub let blockchain = Test.newEmulatorBlockchain() - pub let account = blockchain.createAccount() + pub let account = Test.getAccount(0x0000000000000005) pub fun setup() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let err = blockchain.deployContract( + let err = Test.deployContract( name: "FooContract", - code: contractCode, - account: account, + path: "../contracts/FooContract.cdc", arguments: [{1729: "Harshad"}] ) Test.expect(err, Test.beNil()) - - blockchain.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account.address - })) } pub fun testGetSpecialNumber() { let script = Test.readFile("../scripts/get_special_number.cdc") - let result = blockchain.executeScript(script, []) + let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) let specialNumbers = result.returnValue! as! [FooContract.SpecialNumber] @@ -4582,31 +4873,6 @@ func TestReferenceDeployedContractTypes(t *testing.T) { Test.assertEqual(1729, specialNumber.n) Test.assertEqual("Harshad", specialNumber.trait) } - - pub fun testNewDeploymentWithEmptyArgs() { - let contractCode = Test.readFile("../contracts/FooContract.cdc") - let blockchain2 = Test.newEmulatorBlockchain() - let account2 = blockchain2.createAccount() - let args: {Int: String} = {} - let err = blockchain2.deployContract( - name: "FooContract", - code: contractCode, - account: account2, - arguments: [args] - ) - Test.expect(err, Test.beNil()) - - blockchain2.useConfiguration(Test.Configuration({ - "../contracts/FooContract.cdc": account2.address - })) - - let script = Test.readFile("../scripts/get_special_number.cdc") - let result = blockchain2.executeScript(script, []) - Test.expect(result, Test.beSucceeded()) - - let specialNumbers = result.returnValue! as! [FooContract.SpecialNumber] - Test.expect(specialNumbers, Test.beEmpty()) - } ` fileResolver := func(path string) (string, error) { @@ -4616,7 +4882,7 @@ func TestReferenceDeployedContractTypes(t *testing.T) { case "../scripts/get_special_number.cdc": return scriptCode, nil default: - return "", fmt.Errorf("cannot find import location: %s", path) + return "", fmt.Errorf("cannot find file path: %s", path) } } @@ -4626,14 +4892,23 @@ func TestReferenceDeployedContractTypes(t *testing.T) { if location.Name == "FooContract" { return contractCode, nil } + case common.StringLocation: + if location == "../contracts/FooContract.cdc" { + return contractCode, nil + } } return "", fmt.Errorf("cannot find import location: %s", location.ID()) } + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + runner := NewTestRunner(). WithFileResolver(fileResolver). - WithImportResolver(importResolver) + WithImportResolver(importResolver). + WithContracts(contracts) results, err := runner.RunTests(testCode) require.NoError(t, err) @@ -4650,27 +4925,24 @@ func TestEmulatorBlockchainSnapshotting(t *testing.T) { import Test import BlockchainHelpers - pub let blockchain = Test.newEmulatorBlockchain() - pub let helpers = BlockchainHelpers(blockchain: blockchain) - pub fun test() { - let admin = blockchain.createAccount() - blockchain.createSnapshot(name: "adminCreated") + let admin = Test.createAccount() + Test.createSnapshot(name: "adminCreated") - helpers.mintFlow(to: admin, amount: 1000.0) - blockchain.createSnapshot(name: "adminFunded") + mintFlow(to: admin, amount: 1000.0) + Test.createSnapshot(name: "adminFunded") - var balance = helpers.getFlowBalance(for: admin) + var balance = getFlowBalance(for: admin) Test.assertEqual(1000.0, balance) - blockchain.loadSnapshot(name: "adminCreated") + Test.loadSnapshot(name: "adminCreated") - balance = helpers.getFlowBalance(for: admin) + balance = getFlowBalance(for: admin) Test.assertEqual(0.0, balance) - blockchain.loadSnapshot(name: "adminFunded") + Test.loadSnapshot(name: "adminFunded") - balance = helpers.getFlowBalance(for: admin) + balance = getFlowBalance(for: admin) Test.assertEqual(1000.0, balance) } ` diff --git a/test/test_runner.go b/test/test_runner.go index ab2b94cb..363ccdd8 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -28,7 +28,6 @@ import ( "github.com/logrusorgru/aurora" "github.com/rs/zerolog" - "github.com/onflow/flow-emulator/emulator" "github.com/onflow/flow-go/engine/execution/testutil" "github.com/onflow/flow-go/fvm" "github.com/onflow/flow-go/fvm/environment" @@ -130,7 +129,6 @@ type TestRunner struct { importResolver ImportResolver // fileResolver is used to resolve local files. - // fileResolver FileResolver testRuntime runtime.Runtime @@ -149,9 +147,9 @@ type TestRunner struct { // randomSeed is used for randomized test case execution. randomSeed int64 - // blockchain is mainly used to obtain system-defined - // contracts & their exposed types - blockchain *emulator.Blockchain + contracts map[string]common.Address + + backend *EmulatorBackend } func NewTestRunner() *TestRunner { @@ -167,23 +165,35 @@ func NewTestRunner() *TestRunner { ) } logger := zerolog.New(output).With().Timestamp().Logger().Hook(logCollectionHook) - blockchain, err := emulator.New( - emulator.WithStorageLimitEnabled(false), - emulator.Contracts(commonContracts), - emulator.WithChainID(chain.ChainID()), - ) - if err != nil { - panic(err) - } return &TestRunner{ testRuntime: runtime.NewInterpreterRuntime(runtime.Config{}), logCollection: logCollectionHook, logger: logger, - blockchain: blockchain, + contracts: baseContracts(), } } +func baseContracts() map[string]common.Address { + contracts := make(map[string]common.Address, 0) + serviceAddress := common.Address(chain.ServiceAddress()) + contracts["NonFungibleToken"] = serviceAddress + contracts["MetadataViews"] = serviceAddress + contracts["ViewResolver"] = serviceAddress + for _, addressLocation := range systemContracts { + contract := addressLocation.Name + address := common.Address(addressLocation.Address) + contracts[contract] = address + } + for _, contractDescription := range commonContracts { + contract := contractDescription.Name + address := common.Address(contractDescription.Address) + contracts[contract] = address + } + + return contracts +} + func (r *TestRunner) WithImportResolver(importResolver ImportResolver) *TestRunner { r.importResolver = importResolver return r @@ -204,6 +214,15 @@ func (r *TestRunner) WithRandomSeed(seed int64) *TestRunner { return r } +func (r *TestRunner) WithContracts(contracts map[string]common.Address) *TestRunner { + for contract, address := range contracts { + // We do not want to override the base configuration, + // which includes the mapping for system/common contracts. + r.contracts[contract] = address + } + return r +} + // RunTest runs a single test in the provided test script. func (r *TestRunner) RunTest(script string, funcName string) (result *Result, err error) { defer func() { @@ -312,6 +331,54 @@ func (r *TestRunner) RunTests(script string) (results Results, err error) { return results, err } +func (r *TestRunner) replaceImports(program *ast.Program, code string) string { + sb := strings.Builder{} + importDeclEnd := 0 + + for _, importDeclaration := range program.ImportDeclarations() { + prevImportDeclEnd := importDeclEnd + importDeclEnd = importDeclaration.EndPos.Offset + 1 + + location, ok := importDeclaration.Location.(common.StringLocation) + if !ok { + // keep the import statement it as-is + sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) + continue + } + + var address common.Address + var found bool + if len(importDeclaration.Identifiers) > 0 { + address, found = r.contracts[importDeclaration.Identifiers[0].Identifier] + } else { + address, found = r.contracts[location.String()] + } + if !found { + // keep import statement it as-is + sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) + continue + } + + var importStr string + if strings.Contains(importDeclaration.String(), "from") { + importStr = fmt.Sprintf("0x%s", address) + } else { + // Imports of the form `import "FungibleToken"` should be + // expanded to `import FungibleToken from 0xee82856bf20e2aa6` + importStr = fmt.Sprintf("%s from 0x%s", location, address) + } + + locationStart := importDeclaration.LocationPos.Offset + + sb.WriteString(code[prevImportDeclEnd:locationStart]) + sb.WriteString(importStr) + } + + sb.WriteString(code[importDeclEnd:]) + + return sb.String() +} + func (r *TestRunner) runTestSetup(inter *interpreter.Interpreter) error { if !hasSetup(inter) { return nil @@ -403,12 +470,6 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program Location: testScriptLocation, Environment: env, } - if r.coverageReport != nil { - r.coverageReport.ExcludeLocation(stdlib.CryptoCheckerLocation) - r.coverageReport.ExcludeLocation(stdlib.TestContractLocation) - r.coverageReport.ExcludeLocation(testScriptLocation) - ctx.CoverageReport = r.coverageReport - } // Checker configs env.CheckerConfig.ImportHandler = r.checkerImportHandler(ctx) @@ -451,8 +512,28 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program // Set the storage after checking, because `ParseAndCheckProgram` clears the storage. env.InterpreterConfig.Storage = runtime.NewStorage(ctx.Interface, nil) + script = r.replaceImports(program.Program, script) + newCtx := runtime.Context{ + Interface: newScriptEnvironment(r.logger), + Location: testScriptLocation, + Environment: env, + } + if r.coverageReport != nil { + r.coverageReport.ExcludeLocation(stdlib.CryptoCheckerLocation) + r.coverageReport.ExcludeLocation(stdlib.TestContractLocation) + r.coverageReport.ExcludeLocation(testScriptLocation) + newCtx.CoverageReport = r.coverageReport + } + program, err = r.testRuntime.ParseAndCheckProgram([]byte(script), newCtx) + if err != nil { + return nil, nil, err + } + + // Set the storage after checking, because `ParseAndCheckProgram` clears the storage. + env.InterpreterConfig.Storage = runtime.NewStorage(newCtx.Interface, nil) + _, inter, err := env.Interpret( - ctx.Location, + newCtx.Location, program, nil, ) @@ -504,29 +585,16 @@ func contractValueHandler( declaration *ast.CompositeDeclaration, compositeType *sema.CompositeType, ) sema.ValueDeclaration { - constructorType, constructorArgumentLabels := sema.CompositeLikeConstructorType( + _, constructorArgumentLabels := sema.CompositeLikeConstructorType( checker.Elaboration, declaration, compositeType, ) - // In unit tests, contracts are imported with string locations, e.g - // import FooContract from "../contracts/FooContract.cdc" - if _, ok := compositeType.Location.(common.StringLocation); ok { - return stdlib.StandardLibraryValue{ - Name: declaration.Identifier.Identifier, - Type: constructorType, - DocString: declaration.DocString, - Kind: declaration.DeclarationKind(), - Position: &declaration.Identifier.Pos, - ArgumentLabels: constructorArgumentLabels, - } - } - // For composite types (e.g. contracts) that are deployed on // EmulatorBackend's blockchain, we have to declare the - // define the value declaration as a composite. This is needed - // for nested types that are defined in the composite type, + // value declaration as a composite. This is needed to access + // nested types that are defined in the composite type, // e.g events / structs / resources / enums etc. return stdlib.StandardLibraryValue{ Name: declaration.Identifier.Identifier, @@ -566,6 +634,13 @@ func (r *TestRunner) interpreterContractValueHandler( stdlibHandler, r.coverageReport, ) + backend, ok := testFramework.NewEmulatorBackend().(*EmulatorBackend) + if !ok { + panic(fmt.Errorf("failed to retrieve EmulatorBackend")) + } + backend.fileResolver = r.fileResolver + backend.contracts = r.contracts + r.backend = backend contract, err := stdlib.GetTestContractType(). NewTestContract( inter, @@ -579,33 +654,27 @@ func (r *TestRunner) interpreterContractValueHandler( return contract default: - if _, ok := compositeType.Location.(common.AddressLocation); ok { - invocation, found := contractInvocations[compositeType.Identifier] - if !found { - panic(fmt.Errorf("contract invocation not found")) - } - parameterTypes := make([]sema.Type, len(compositeType.ConstructorParameters)) - for i, constructorParameter := range compositeType.ConstructorParameters { - parameterTypes[i] = constructorParameter.TypeAnnotation.Type - } - - value, err := inter.InvokeFunctionValue( - constructorGenerator(common.Address{}), - invocation.ConstructorArguments, - invocation.ArgumentTypes, - parameterTypes, - invocationRange, - ) - if err != nil { - panic(err) - } + invocation, found := contractInvocations[compositeType.Identifier] + if !found { + panic(fmt.Errorf("contract invocation not found")) + } + parameterTypes := make([]sema.Type, len(compositeType.ConstructorParameters)) + for i, constructorParameter := range compositeType.ConstructorParameters { + parameterTypes[i] = constructorParameter.TypeAnnotation.Type + } - return value.(*interpreter.CompositeValue) + value, err := inter.InvokeFunctionValue( + constructorGenerator(common.Address{}), + invocation.ConstructorArguments, + invocation.ArgumentTypes, + parameterTypes, + invocationRange, + ) + if err != nil { + panic(err) } - // During tests, imported contracts can be constructed using the constructor, - // similar to structs. Therefore, generate a constructor function. - return constructorGenerator(common.Address{}) + return value.(*interpreter.CompositeValue) } } } @@ -685,7 +754,7 @@ func (r *TestRunner) parseAndCheckImport( if ok { // System-defined contracts are obtained from // the blockchain. - account, err := r.blockchain.GetAccount( + account, err := r.backend.blockchain.GetAccount( flow.Address(addressLocation.Address), ) if err != nil { @@ -725,7 +794,7 @@ func (r *TestRunner) parseAndCheckImport( if ok { // System-defined contracts are obtained from // the blockchain. - account, err := r.blockchain.GetAccount( + account, err := r.backend.blockchain.GetAccount( flow.Address(addressLoc.Address), ) if err != nil { @@ -742,9 +811,27 @@ func (r *TestRunner) parseAndCheckImport( return sema.ElaborationImport{ Elaboration: program.Elaboration, }, nil - } else { - return nil, fmt.Errorf("nested imports are not supported") } + + stringLocation, ok := importedLocation.(common.StringLocation) + if ok { + code, err := r.importResolver(stringLocation) + if err != nil { + return nil, err + } + program, err := env.ParseAndCheckProgram( + []byte(code), stringLocation, true, + ) + if err != nil { + return nil, err + } + + return sema.ElaborationImport{ + Elaboration: program.Elaboration, + }, nil + } + + return nil, fmt.Errorf("unable to import location: %s", importedLocation) } } From 831bc2ea7d64857e71b462d07d5260f55a8c4622 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 20 Sep 2023 18:32:25 +0300 Subject: [PATCH 05/20] Setup emulator blockchain with same runtime as the script environment --- test/emulator_backend.go | 42 +------ test/test_framework_provider.go | 2 + test/test_framework_test.go | 49 ++++++-- test/test_runner.go | 210 +++++++++++++------------------- 4 files changed, 135 insertions(+), 168 deletions(-) diff --git a/test/emulator_backend.go b/test/emulator_backend.go index 39eacdce..3f4058ef 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -32,7 +32,6 @@ import ( "github.com/onflow/cadence/runtime/common" "github.com/onflow/cadence/runtime/interpreter" "github.com/onflow/cadence/runtime/parser" - "github.com/onflow/cadence/runtime/sema" "github.com/onflow/cadence/runtime/stdlib" "github.com/onflow/flow-emulator/adapters" "github.com/onflow/flow-emulator/convert" @@ -70,22 +69,6 @@ func newSystemClock() *systemClock { return &systemClock{} } -// This type holds the necessary information for each contract deployment. -// These are consumed in InterpreterConfig.ContractValueHandler function, -// in order to construct the contract value for imported contracts in -// test scripts. -type deployedContractConstructorInvocation struct { - ConstructorArguments []interpreter.Value - ArgumentTypes []sema.Type - Address common.Address -} - -// This slice records all contract deployments in test scripts. -var contractInvocations = make( - map[string]deployedContractConstructorInvocation, - 0, -) - // EmulatorBackend is the emulator-backed implementation of the interpreter.TestFramework. type EmulatorBackend struct { blockchain *emulator.Blockchain @@ -163,6 +146,7 @@ func NewEmulatorBackend( fileResolver FileResolver, stdlibHandler stdlib.StandardLibraryHandler, coverageReport *runtime.CoverageReport, + testRuntime runtime.Runtime, ) *EmulatorBackend { logCollectionHook := newLogCollectionHook() var blockchain *emulator.Blockchain @@ -171,9 +155,13 @@ func NewEmulatorBackend( blockchain = newBlockchain( logCollectionHook, emulator.WithCoverageReport(coverageReport), + emulator.WithRuntime(testRuntime), ) } else { - blockchain = newBlockchain(logCollectionHook) + blockchain = newBlockchain( + logCollectionHook, + emulator.WithRuntime(testRuntime), + ) } clock := newSystemClock() blockchain.SetClock(clock) @@ -499,24 +487,6 @@ func (e *EmulatorBackend) DeployContract( return result.Error } - argTypes := make([]sema.Type, 0) - for _, arg := range args { - staticType := arg.StaticType(inter) - argType, err := inter.ConvertStaticToSemaType(staticType) - if err != nil { - panic(err) - } - argTypes = append(argTypes, argType) - } - // We record the successful contract deployment, along with any - // supplied arguments, so that we can reconstruct a contract value - // in test scripts. - contractInvocations[name] = deployedContractConstructorInvocation{ - ConstructorArguments: args, - ArgumentTypes: argTypes, - Address: account.Address, - } - return e.CommitBlock() } diff --git a/test/test_framework_provider.go b/test/test_framework_provider.go index 5091e4fe..6800b7b5 100644 --- a/test/test_framework_provider.go +++ b/test/test_framework_provider.go @@ -70,6 +70,7 @@ func NewTestFrameworkProvider( fileResolver FileResolver, stdlibHandler stdlib.StandardLibraryHandler, coverageReport *runtime.CoverageReport, + testRuntime runtime.Runtime, ) stdlib.TestFramework { provider := &TestFrameworkProvider{ fileResolver: fileResolver, @@ -80,6 +81,7 @@ func NewTestFrameworkProvider( fileResolver, stdlibHandler, coverageReport, + testRuntime, ) return provider diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 6ca76ebe..b70aa832 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -582,6 +582,10 @@ func TestImportBuiltinContracts(t *testing.T) { const testCode = ` import Test + import "ExampleNFT" + import "NonFungibleToken" + import "NFTStorefrontV2" + import "FlowToken" pub let account = Test.createAccount() @@ -598,13 +602,30 @@ func TestImportBuiltinContracts(t *testing.T) { Test.expect(result, Test.beSucceeded()) } - pub fun testGetIntegerTrait() { + pub fun testImportCommonContracts() { let script = Test.readFile("../scripts/import_common_contracts.cdc") let result = Test.executeScript(script, []) Test.expect(result, Test.beSucceeded()) Test.assertEqual(true, result.returnValue! as! Bool) } + + pub fun testExampleNFT() { + let storagePath = ExampleNFT.MinterStoragePath + Test.assertEqual(/storage/exampleNFTMinter, storagePath) + + Test.assertEqual( + "A.0000000000000001.NonFungibleToken", + Type().identifier + ) + + let publicPath = NFTStorefrontV2.StorefrontPublicPath + Test.assertEqual(/public/NFTStorefrontV2, publicPath) + + let vault <- FlowToken.createEmptyVault() + Test.assertEqual(0.0, vault.balance) + destroy <- vault + } ` const transactionCode = ` @@ -661,13 +682,23 @@ func TestImportBuiltinContracts(t *testing.T) { } } - runner := NewTestRunner().WithFileResolver(fileResolver) + importResolver := func(location common.Location) (string, error) { + return "", fmt.Errorf("cannot find import location: %s", location) + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithImportResolver(importResolver) result, err := runner.RunTest(testCode, "testSetupExampleNFTCollection") require.NoError(t, err) require.NoError(t, result.Error) - result, err = runner.RunTest(testCode, "testGetIntegerTrait") + result, err = runner.RunTest(testCode, "testImportCommonContracts") + require.NoError(t, err) + require.NoError(t, result.Error) + + result, err = runner.RunTest(testCode, "testExampleNFT") require.NoError(t, err) require.NoError(t, result.Error) } @@ -704,7 +735,7 @@ func TestUsingEnv(t *testing.T) { import Test pub fun test() { - let acc = getAccount(0x01) + let acc = getAccount(0x10) Test.assertEqual(0.0, acc.balance) } ` @@ -743,7 +774,7 @@ func TestUsingEnv(t *testing.T) { init() {} pub fun getBalance(): UFix64 { - let acc = getAccount(0x01) + let acc = getAccount(0x10) return acc.balance } } @@ -3021,7 +3052,8 @@ func TestReplacingImports(t *testing.T) { func TestReplaceImports(t *testing.T) { t.Parallel() - emulatorBackend := NewEmulatorBackend(nil, nil, nil) + runtime := runtime.NewInterpreterRuntime(runtime.Config{}) + emulatorBackend := NewEmulatorBackend(nil, nil, nil, runtime) emulatorBackend.contracts = map[string]common.Address{ "C1": {0, 0, 0, 0, 0, 0, 0, 1}, "C2": {0, 0, 0, 0, 0, 0, 0, 2}, @@ -3174,7 +3206,8 @@ func TestServiceAccount(t *testing.T) { t.Run("retrieve from EmulatorBackend", func(t *testing.T) { t.Parallel() - emulatorBackend := NewEmulatorBackend(nil, nil, nil) + testRuntime := runtime.NewInterpreterRuntime(runtime.Config{}) + emulatorBackend := NewEmulatorBackend(nil, nil, nil, testRuntime) serviceAccount, err := emulatorBackend.ServiceAccount() @@ -3443,7 +3476,7 @@ func TestCoverageReportForUnitTests(t *testing.T) { assert.EqualValues( t, map[int]int{ - 6: 2, 14: 1, 18: 10, 19: 1, 20: 9, 21: 1, 22: 8, 23: 1, + 6: 1, 14: 1, 18: 10, 19: 1, 20: 9, 21: 1, 22: 8, 23: 1, 24: 7, 25: 1, 26: 6, 27: 1, 30: 5, 31: 4, 34: 1, }, coverage.LineHits, diff --git a/test/test_runner.go b/test/test_runner.go index 363ccdd8..eda61607 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -21,22 +21,19 @@ package test import ( "fmt" "math/rand" - "os" "regexp" "strings" - "github.com/logrusorgru/aurora" "github.com/rs/zerolog" - "github.com/onflow/flow-go/engine/execution/testutil" - "github.com/onflow/flow-go/fvm" - "github.com/onflow/flow-go/fvm/environment" "github.com/onflow/flow-go/model/flow" "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/runtime/ast" "github.com/onflow/cadence/runtime/common" + "github.com/onflow/cadence/runtime/errors" "github.com/onflow/cadence/runtime/interpreter" + "github.com/onflow/cadence/runtime/parser" "github.com/onflow/cadence/runtime/sema" "github.com/onflow/cadence/runtime/stdlib" ) @@ -135,63 +132,22 @@ type TestRunner struct { coverageReport *runtime.CoverageReport - // logger is injected as the program logger for the script - // environment. - logger zerolog.Logger - - // logCollection is a hook attached in the program logger of - // the script environment, in order to aggregate and expose - // log messages from test cases and contracts. - logCollection *logCollectionHook - // randomSeed is used for randomized test case execution. randomSeed int64 contracts map[string]common.Address + testFramework stdlib.TestFramework + backend *EmulatorBackend + + storage *runtime.Storage } func NewTestRunner() *TestRunner { - logCollectionHook := newLogCollectionHook() - output := zerolog.ConsoleWriter{Out: os.Stdout} - output.FormatMessage = func(i interface{}) string { - msg := i.(string) - return strings.Replace( - msg, - "Cadence log:", - aurora.Colorize("LOG:", aurora.BlueFg|aurora.BoldFm).String(), - 1, - ) - } - logger := zerolog.New(output).With().Timestamp().Logger().Hook(logCollectionHook) - return &TestRunner{ - testRuntime: runtime.NewInterpreterRuntime(runtime.Config{}), - logCollection: logCollectionHook, - logger: logger, - contracts: baseContracts(), - } -} - -func baseContracts() map[string]common.Address { - contracts := make(map[string]common.Address, 0) - serviceAddress := common.Address(chain.ServiceAddress()) - contracts["NonFungibleToken"] = serviceAddress - contracts["MetadataViews"] = serviceAddress - contracts["ViewResolver"] = serviceAddress - for _, addressLocation := range systemContracts { - contract := addressLocation.Name - address := common.Address(addressLocation.Address) - contracts[contract] = address + contracts: baseContracts(), } - for _, contractDescription := range commonContracts { - contract := contractDescription.Name - address := common.Address(contractDescription.Address) - contracts[contract] = address - } - - return contracts } func (r *TestRunner) WithImportResolver(importResolver ImportResolver) *TestRunner { @@ -444,7 +400,7 @@ func (r *TestRunner) invokeTestFunction(inter *interpreter.Interpreter, funcName // logs from their respective contracts, also appear in the resulting // string slice. func (r *TestRunner) Logs() []string { - return r.logCollection.Logs + return r.backend.Logs() } func recoverPanics(onError func(error)) { @@ -461,15 +417,39 @@ func recoverPanics(onError func(error)) { func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program, *interpreter.Interpreter, error) { config := runtime.Config{ - CoverageReport: r.coverageReport, + AccountLinkingEnabled: true, + AttachmentsEnabled: true, + CapabilityControllersEnabled: true, + CoverageReport: r.coverageReport, } env := runtime.NewBaseInterpreterEnvironment(config) + r.testRuntime = runtime.NewInterpreterRuntime(config) + + r.testFramework = NewTestFrameworkProvider( + r.fileResolver, + env, + r.coverageReport, + r.testRuntime, + ) + backend, ok := r.testFramework.NewEmulatorBackend().(*EmulatorBackend) + if !ok { + panic(fmt.Errorf("failed to retrieve EmulatorBackend")) + } + backend.fileResolver = r.fileResolver + backend.contracts = r.contracts + r.backend = backend ctx := runtime.Context{ - Interface: newScriptEnvironment(r.logger), + Interface: r.backend.blockchain.NewScriptEnvironment(), Location: testScriptLocation, Environment: env, } + if r.coverageReport != nil { + r.coverageReport.ExcludeLocation(stdlib.CryptoCheckerLocation) + r.coverageReport.ExcludeLocation(stdlib.TestContractLocation) + r.coverageReport.ExcludeLocation(testScriptLocation) + ctx.CoverageReport = r.coverageReport + } // Checker configs env.CheckerConfig.ImportHandler = r.checkerImportHandler(ctx) @@ -488,12 +468,13 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program // Thus, need to properly handle them. Make this nil for now. env.InterpreterConfig.InjectedCompositeFieldsHandler = nil - program, err := r.testRuntime.ParseAndCheckProgram([]byte(script), ctx) + code, err := parser.ParseProgram(nil, []byte(script), parser.Config{}) if err != nil { - return nil, nil, err + panic(err) } + script = r.replaceImports(code, script) - for _, funcDecl := range program.Program.FunctionDeclarations() { + for _, funcDecl := range code.FunctionDeclarations() { funcName := funcDecl.Identifier.Identifier if !strings.HasPrefix(funcName, testFunctionPrefix) { @@ -509,31 +490,17 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program } } - // Set the storage after checking, because `ParseAndCheckProgram` clears the storage. - env.InterpreterConfig.Storage = runtime.NewStorage(ctx.Interface, nil) - - script = r.replaceImports(program.Program, script) - newCtx := runtime.Context{ - Interface: newScriptEnvironment(r.logger), - Location: testScriptLocation, - Environment: env, - } - if r.coverageReport != nil { - r.coverageReport.ExcludeLocation(stdlib.CryptoCheckerLocation) - r.coverageReport.ExcludeLocation(stdlib.TestContractLocation) - r.coverageReport.ExcludeLocation(testScriptLocation) - newCtx.CoverageReport = r.coverageReport - } - program, err = r.testRuntime.ParseAndCheckProgram([]byte(script), newCtx) + program, err := r.testRuntime.ParseAndCheckProgram([]byte(script), ctx) if err != nil { return nil, nil, err } // Set the storage after checking, because `ParseAndCheckProgram` clears the storage. - env.InterpreterConfig.Storage = runtime.NewStorage(newCtx.Interface, nil) + r.storage = runtime.NewStorage(ctx.Interface, nil) + env.InterpreterConfig.Storage = r.storage _, inter, err := env.Interpret( - newCtx.Location, + ctx.Location, program, nil, ) @@ -629,22 +596,10 @@ func (r *TestRunner) interpreterContractValueHandler( return contract case stdlib.TestContractLocation: - testFramework := NewTestFrameworkProvider( - r.fileResolver, - stdlibHandler, - r.coverageReport, - ) - backend, ok := testFramework.NewEmulatorBackend().(*EmulatorBackend) - if !ok { - panic(fmt.Errorf("failed to retrieve EmulatorBackend")) - } - backend.fileResolver = r.fileResolver - backend.contracts = r.contracts - r.backend = backend contract, err := stdlib.GetTestContractType(). NewTestContract( inter, - testFramework, + r.testFramework, constructorGenerator(common.Address{}), invocationRange, ) @@ -654,27 +609,33 @@ func (r *TestRunner) interpreterContractValueHandler( return contract default: - invocation, found := contractInvocations[compositeType.Identifier] - if !found { - panic(fmt.Errorf("contract invocation not found")) - } - parameterTypes := make([]sema.Type, len(compositeType.ConstructorParameters)) - for i, constructorParameter := range compositeType.ConstructorParameters { - parameterTypes[i] = constructorParameter.TypeAnnotation.Type + var storedValue interpreter.Value + + switch location := compositeType.Location.(type) { + case common.AddressLocation: + storageMap := r.storage.GetStorageMap( + location.Address, + runtime.StorageDomainContract, + false, + ) + if storageMap != nil { + storedValue = storageMap.ReadValue( + inter, + interpreter.StringStorageMapKey(location.Name), + ) + } } - value, err := inter.InvokeFunctionValue( - constructorGenerator(common.Address{}), - invocation.ConstructorArguments, - invocation.ArgumentTypes, - parameterTypes, - invocationRange, - ) - if err != nil { - panic(err) + if storedValue == nil { + panic( + errors.NewDefaultUserError( + "failed to load contract: %s", + compositeType.Location, + ), + ) } - return value.(*interpreter.CompositeValue) + return storedValue.(*interpreter.CompositeValue) } } } @@ -717,25 +678,6 @@ func (r *TestRunner) interpreterImportHandler(ctx runtime.Context) interpreter.I } } -// newScriptEnvironment creates an environment for test scripts to run. -// Leverages the functionality of FVM. -func newScriptEnvironment(logger zerolog.Logger) environment.Environment { - vm := fvm.NewVirtualMachine() - ctx := fvm.NewContext(fvm.WithLogger(zerolog.Nop())) - snapshotTree := testutil.RootBootstrappedLedger(vm, ctx) - environmentParams := environment.DefaultEnvironmentParams() - environmentParams.ProgramLoggerParams = environment.ProgramLoggerParams{ - Logger: logger, - CadenceLoggingEnabled: true, - MetricsReporter: environment.NoopMetricsReporter{}, - } - - return environment.NewScriptEnvironmentFromStorageSnapshot( - environmentParams, - snapshotTree, - ) -} - func (r *TestRunner) parseAndCheckImport( location common.Location, startCtx runtime.Context, @@ -846,6 +788,26 @@ func (r *TestRunner) parseAndCheckImport( return program.Program, program.Elaboration, nil } +func baseContracts() map[string]common.Address { + contracts := make(map[string]common.Address, 0) + serviceAddress := common.Address(chain.ServiceAddress()) + contracts["NonFungibleToken"] = serviceAddress + contracts["MetadataViews"] = serviceAddress + contracts["ViewResolver"] = serviceAddress + for _, addressLocation := range systemContracts { + contract := addressLocation.Name + address := common.Address(addressLocation.Address) + contracts[contract] = address + } + for _, contractDescription := range commonContracts { + contract := contractDescription.Name + address := common.Address(contractDescription.Address) + contracts[contract] = address + } + + return contracts +} + // PrettyPrintResults is a utility function to pretty print the test results. func PrettyPrintResults(results Results, scriptPath string) string { var sb strings.Builder From 46840cf0ba8d8bc787dea08d4b7a8586e5f0f6c7 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Thu, 21 Sep 2023 16:33:42 +0300 Subject: [PATCH 06/20] Allow unit tests to make use of self.account in contracts --- test/test_framework_test.go | 122 ++++++++++++++++++++++++++++++++++++ test/test_runner.go | 44 +++++++++++-- 2 files changed, 162 insertions(+), 4 deletions(-) diff --git a/test/test_framework_test.go b/test/test_framework_test.go index b70aa832..d9f06e40 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -4985,3 +4985,125 @@ func TestEmulatorBlockchainSnapshotting(t *testing.T) { require.NoError(t, err) require.NoError(t, result.Error) } + +func TestEnvironmentForUnitTests(t *testing.T) { + t.Parallel() + + const fooContract = ` + pub contract FooContract { + pub let specialNumbers: {Int: String} + + init() { + self.specialNumbers = { + 1729: "Harshad", + 8128: "Harmonic", + 41041: "Carmichael" + } + self.account.save(self.specialNumbers, to: /storage/specialNumbers) + } + + pub fun getSpecialNumbers(): {Int: String} { + return self.account.load<{Int: String}>(from: /storage/specialNumbers)! + } + + pub fun addSpecialNumber(_ n: Int, _ trait: String) { + self.specialNumbers[n] = trait + self.account.load<{Int: String}>(from: /storage/specialNumbers)! + self.account.save(self.specialNumbers, to: /storage/specialNumbers) + } + + pub fun getIntegerTrait(_ n: Int): String { + if self.specialNumbers.containsKey(n) { + return self.specialNumbers[n]! + } + + return "Enormous" + } + + pub fun getBlockHeight(): UInt64 { + return getCurrentBlock().height + } + } + ` + + const code = ` + import Test + import BlockchainHelpers + import FooContract from "../contracts/FooContract.cdc" + + pub fun setup() { + let err = Test.deployContract( + name: "FooContract", + path: "../contracts/FooContract.cdc", + arguments: [] + ) + + Test.expect(err, Test.beNil()) + } + + pub fun testAddSpecialNumber() { + // Act + FooContract.addSpecialNumber(78557, "Sierpinski") + + // Assert + Test.assertEqual("Sierpinski", FooContract.getIntegerTrait(78557)) + + let specialNumbers = FooContract.getSpecialNumbers() + let expected: {Int: String} = { + 8128: "Harmonic", + 1729: "Harshad", + 41041: "Carmichael", + 78557: "Sierpinski" + } + Test.assertEqual(expected, specialNumbers) + } + + pub fun testGetCurrentBlockHeight() { + // Act + let height = FooContract.getBlockHeight() + + // Assert + Test.expect(height, Test.beGreaterThan(UInt64(1))) + } + ` + + fileResolver := func(path string) (string, error) { + switch path { + case "../contracts/FooContract.cdc": + return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + importResolver := func(location common.Location) (string, error) { + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "../contracts/FooContract.cdc" { + return fooContract, nil + } + } + + return "", fmt.Errorf("cannot find import location: %s", location.ID()) + } + + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 9}, + } + + runner := NewTestRunner(). + WithFileResolver(fileResolver). + WithImportResolver(importResolver). + WithContracts(contracts) + + results, err := runner.RunTests(code) + + require.NoError(t, err) + for _, result := range results { + assert.NoError(t, result.Error) + } +} diff --git a/test/test_runner.go b/test/test_runner.go index eda61607..5af67c3e 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -463,10 +463,46 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program // returned from blockchain to the test script) env.InterpreterConfig.ContractValueHandler = r.interpreterContractValueHandler(env) - // TODO: The default injected fields handler only supports 'address' locations. - // However, during tests, it is possible to get non-address locations. e.g: file paths. - // Thus, need to properly handle them. Make this nil for now. - env.InterpreterConfig.InjectedCompositeFieldsHandler = nil + env.InterpreterConfig.InjectedCompositeFieldsHandler = func( + inter *interpreter.Interpreter, + location common.Location, + qualifiedIdentifier string, + compositeKind common.CompositeKind, + ) map[string]interpreter.Value { + + switch location { + case stdlib.CryptoCheckerLocation: + return nil + + default: + switch compositeKind { + case common.CompositeKindContract: + var address common.Address + + switch location := location.(type) { + case common.AddressLocation: + address = location.Address + default: + return nil + } + + addressValue := interpreter.NewAddressValue( + inter, + address, + ) + + return map[string]interpreter.Value{ + sema.ContractAccountFieldName: stdlib.NewAuthAccountValue( + inter, + env, + addressValue, + ), + } + } + } + + return nil + } code, err := parser.ParseProgram(nil, []byte(script), parser.Config{}) if err != nil { From 053513cd58d1922ce40828c32bf86aa6241143af Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 27 Sep 2023 09:23:39 +0300 Subject: [PATCH 07/20] Change number of initial accounts to 10 --- test/emulator_backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/emulator_backend.go b/test/emulator_backend.go index 3f4058ef..d5821753 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -53,7 +53,7 @@ const helperFilePrefix = "\x00helper/" // The number of predefined accounts that are created // upon initialization of EmulatorBackend. -const initialAccountsNumber = 25 +const initialAccountsNumber = 10 var _ stdlib.Blockchain = &EmulatorBackend{} From 7a1a6b94dda14eb979ae70e22605645f208eb6a5 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 27 Sep 2023 09:26:23 +0300 Subject: [PATCH 08/20] Rename TestFramework's NewEmulatorBackend method to EmulatorBackend --- test/test_framework_provider.go | 22 ++++++++++------------ test/test_runner.go | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/test/test_framework_provider.go b/test/test_framework_provider.go index 6800b7b5..33442f70 100644 --- a/test/test_framework_provider.go +++ b/test/test_framework_provider.go @@ -35,7 +35,7 @@ type TestFrameworkProvider struct { coverageReport *runtime.CoverageReport - EmulatorBackend *EmulatorBackend + emulatorBackend *EmulatorBackend } func (tf *TestFrameworkProvider) ReadFile(path string) (string, error) { @@ -62,8 +62,8 @@ func (tf *TestFrameworkProvider) ReadFile(path string) (string, error) { return tf.fileResolver(path) } -func (tf *TestFrameworkProvider) NewEmulatorBackend() stdlib.Blockchain { - return tf.EmulatorBackend +func (tf *TestFrameworkProvider) EmulatorBackend() stdlib.Blockchain { + return tf.emulatorBackend } func NewTestFrameworkProvider( @@ -72,17 +72,15 @@ func NewTestFrameworkProvider( coverageReport *runtime.CoverageReport, testRuntime runtime.Runtime, ) stdlib.TestFramework { - provider := &TestFrameworkProvider{ + return &TestFrameworkProvider{ fileResolver: fileResolver, stdlibHandler: stdlibHandler, coverageReport: coverageReport, + emulatorBackend: NewEmulatorBackend( + fileResolver, + stdlibHandler, + coverageReport, + testRuntime, + ), } - provider.EmulatorBackend = NewEmulatorBackend( - fileResolver, - stdlibHandler, - coverageReport, - testRuntime, - ) - - return provider } diff --git a/test/test_runner.go b/test/test_runner.go index 5af67c3e..72836a11 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -431,7 +431,7 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program r.coverageReport, r.testRuntime, ) - backend, ok := r.testFramework.NewEmulatorBackend().(*EmulatorBackend) + backend, ok := r.testFramework.EmulatorBackend().(*EmulatorBackend) if !ok { panic(fmt.Errorf("failed to retrieve EmulatorBackend")) } From 51c46cbac987bda96482a0513ce3bd33ec0197cf Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 27 Sep 2023 09:36:59 +0300 Subject: [PATCH 09/20] Add test case with usage of undeployed contract --- test/test_framework_test.go | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/test/test_framework_test.go b/test/test_framework_test.go index d9f06e40..4b19cd8a 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -575,6 +575,70 @@ func TestImportContract(t *testing.T) { _, err := runner.RunTest(code, "test") require.NoError(t, err) }) + + t.Run("undeployed contract", func(t *testing.T) { + t.Parallel() + + const code = ` + import Test + import FooContract from "./FooContract" + + pub fun test() { + Test.assertEqual("Hello", FooContract.sayHello()) + } + ` + + const fooContract = ` + pub contract FooContract { + init() {} + + pub fun sayHello(): String { + return "Hello" + } + } + ` + + importResolver := func(location common.Location) (string, error) { + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + case common.StringLocation: + if location == "./FooContract" { + return fooContract, nil + } + } + + return "", fmt.Errorf("unsupported import %s", location) + } + + fileResolver := func(path string) (string, error) { + switch path { + case "./FooContract": + return fooContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + contracts := map[string]common.Address{ + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithContracts(contracts). + WithFileResolver(fileResolver) + + result, err := runner.RunTest(code, "test") + require.NoError(t, err) + assert.ErrorContains( + t, + result.Error, + "failed to load contract: 0000000000000005.FooContract", + ) + }) } func TestImportBuiltinContracts(t *testing.T) { From 01e13cf20bc34673095a079d849b438af1e426f1 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 27 Sep 2023 09:49:36 +0300 Subject: [PATCH 10/20] Remove custom InjectedCompositeFieldsHandler and use the default one from Cadence --- test/test_runner.go | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/test/test_runner.go b/test/test_runner.go index 72836a11..e562eb7a 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -463,47 +463,6 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program // returned from blockchain to the test script) env.InterpreterConfig.ContractValueHandler = r.interpreterContractValueHandler(env) - env.InterpreterConfig.InjectedCompositeFieldsHandler = func( - inter *interpreter.Interpreter, - location common.Location, - qualifiedIdentifier string, - compositeKind common.CompositeKind, - ) map[string]interpreter.Value { - - switch location { - case stdlib.CryptoCheckerLocation: - return nil - - default: - switch compositeKind { - case common.CompositeKindContract: - var address common.Address - - switch location := location.(type) { - case common.AddressLocation: - address = location.Address - default: - return nil - } - - addressValue := interpreter.NewAddressValue( - inter, - address, - ) - - return map[string]interpreter.Value{ - sema.ContractAccountFieldName: stdlib.NewAuthAccountValue( - inter, - env, - addressValue, - ), - } - } - } - - return nil - } - code, err := parser.ParseProgram(nil, []byte(script), parser.Config{}) if err != nil { panic(err) From 24f170f02db636416cddf7301fd190e719105d25 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 27 Sep 2023 10:25:14 +0300 Subject: [PATCH 11/20] Reuse the replaceImports method of EmulatorBackend --- test/emulator_backend.go | 15 ++++++------ test/test_runner.go | 50 +++------------------------------------- 2 files changed, 11 insertions(+), 54 deletions(-) diff --git a/test/emulator_backend.go b/test/emulator_backend.go index d5821753..3497121d 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -675,15 +675,16 @@ func (e *EmulatorBackend) replaceImports(code string) string { } var address common.Address + var found bool if len(importDeclaration.Identifiers) > 0 { - address, ok = e.contracts[importDeclaration.Identifiers[0].Identifier] - if !ok { - // keep import statement it as-is - sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) - continue - } + address, found = e.contracts[importDeclaration.Identifiers[0].Identifier] } else { - address = e.contracts[location.String()] + address, found = e.contracts[location.String()] + } + if !found { + // keep import statement it as-is + sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) + continue } var importStr string diff --git a/test/test_runner.go b/test/test_runner.go index e562eb7a..6af6a14d 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -287,52 +287,8 @@ func (r *TestRunner) RunTests(script string) (results Results, err error) { return results, err } -func (r *TestRunner) replaceImports(program *ast.Program, code string) string { - sb := strings.Builder{} - importDeclEnd := 0 - - for _, importDeclaration := range program.ImportDeclarations() { - prevImportDeclEnd := importDeclEnd - importDeclEnd = importDeclaration.EndPos.Offset + 1 - - location, ok := importDeclaration.Location.(common.StringLocation) - if !ok { - // keep the import statement it as-is - sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) - continue - } - - var address common.Address - var found bool - if len(importDeclaration.Identifiers) > 0 { - address, found = r.contracts[importDeclaration.Identifiers[0].Identifier] - } else { - address, found = r.contracts[location.String()] - } - if !found { - // keep import statement it as-is - sb.WriteString(code[prevImportDeclEnd:importDeclEnd]) - continue - } - - var importStr string - if strings.Contains(importDeclaration.String(), "from") { - importStr = fmt.Sprintf("0x%s", address) - } else { - // Imports of the form `import "FungibleToken"` should be - // expanded to `import FungibleToken from 0xee82856bf20e2aa6` - importStr = fmt.Sprintf("%s from 0x%s", location, address) - } - - locationStart := importDeclaration.LocationPos.Offset - - sb.WriteString(code[prevImportDeclEnd:locationStart]) - sb.WriteString(importStr) - } - - sb.WriteString(code[importDeclEnd:]) - - return sb.String() +func (r *TestRunner) replaceImports(code string) string { + return r.backend.replaceImports(code) } func (r *TestRunner) runTestSetup(inter *interpreter.Interpreter) error { @@ -467,7 +423,6 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program if err != nil { panic(err) } - script = r.replaceImports(code, script) for _, funcDecl := range code.FunctionDeclarations() { funcName := funcDecl.Identifier.Identifier @@ -485,6 +440,7 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program } } + script = r.replaceImports(script) program, err := r.testRuntime.ParseAndCheckProgram([]byte(script), ctx) if err != nil { return nil, nil, err From 97e8e1e08e9bf6d18bdab5f0fe05612095b295eb Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 27 Sep 2023 11:38:37 +0300 Subject: [PATCH 12/20] Remove the emulator.WithRuntime() config --- test/emulator_backend.go | 3 --- test/test_framework_provider.go | 2 -- test/test_framework_test.go | 6 ++---- test/test_runner.go | 1 - 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/test/emulator_backend.go b/test/emulator_backend.go index 3497121d..3d820755 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -146,7 +146,6 @@ func NewEmulatorBackend( fileResolver FileResolver, stdlibHandler stdlib.StandardLibraryHandler, coverageReport *runtime.CoverageReport, - testRuntime runtime.Runtime, ) *EmulatorBackend { logCollectionHook := newLogCollectionHook() var blockchain *emulator.Blockchain @@ -155,12 +154,10 @@ func NewEmulatorBackend( blockchain = newBlockchain( logCollectionHook, emulator.WithCoverageReport(coverageReport), - emulator.WithRuntime(testRuntime), ) } else { blockchain = newBlockchain( logCollectionHook, - emulator.WithRuntime(testRuntime), ) } clock := newSystemClock() diff --git a/test/test_framework_provider.go b/test/test_framework_provider.go index 33442f70..ee13782f 100644 --- a/test/test_framework_provider.go +++ b/test/test_framework_provider.go @@ -70,7 +70,6 @@ func NewTestFrameworkProvider( fileResolver FileResolver, stdlibHandler stdlib.StandardLibraryHandler, coverageReport *runtime.CoverageReport, - testRuntime runtime.Runtime, ) stdlib.TestFramework { return &TestFrameworkProvider{ fileResolver: fileResolver, @@ -80,7 +79,6 @@ func NewTestFrameworkProvider( fileResolver, stdlibHandler, coverageReport, - testRuntime, ), } } diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 4b19cd8a..ee92294c 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -3116,8 +3116,7 @@ func TestReplacingImports(t *testing.T) { func TestReplaceImports(t *testing.T) { t.Parallel() - runtime := runtime.NewInterpreterRuntime(runtime.Config{}) - emulatorBackend := NewEmulatorBackend(nil, nil, nil, runtime) + emulatorBackend := NewEmulatorBackend(nil, nil, nil) emulatorBackend.contracts = map[string]common.Address{ "C1": {0, 0, 0, 0, 0, 0, 0, 1}, "C2": {0, 0, 0, 0, 0, 0, 0, 2}, @@ -3270,8 +3269,7 @@ func TestServiceAccount(t *testing.T) { t.Run("retrieve from EmulatorBackend", func(t *testing.T) { t.Parallel() - testRuntime := runtime.NewInterpreterRuntime(runtime.Config{}) - emulatorBackend := NewEmulatorBackend(nil, nil, nil, testRuntime) + emulatorBackend := NewEmulatorBackend(nil, nil, nil) serviceAccount, err := emulatorBackend.ServiceAccount() diff --git a/test/test_runner.go b/test/test_runner.go index 6af6a14d..4caa0602 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -385,7 +385,6 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program r.fileResolver, env, r.coverageReport, - r.testRuntime, ) backend, ok := r.testFramework.EmulatorBackend().(*EmulatorBackend) if !ok { From 05feb43151933471a7bc3ad97314c5652d099552 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Fri, 29 Sep 2023 09:20:25 +0300 Subject: [PATCH 13/20] Refactor logic for parseCheckAndInterpret method Also extract a helper function for initializing the test environment. --- test/test_runner.go | 99 +++++++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/test/test_runner.go b/test/test_runner.go index 4caa0602..f6129aa6 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -371,14 +371,67 @@ func recoverPanics(onError func(error)) { } } -func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program, *interpreter.Interpreter, error) { +func (r *TestRunner) parseCheckAndInterpret(script string) ( + *interpreter.Program, + *interpreter.Interpreter, + error, +) { + env, ctx := r.initializeEnvironment() + + astProgram, err := parser.ParseProgram(nil, []byte(script), parser.Config{}) + if err != nil { + return nil, nil, err + } + + for _, funcDecl := range astProgram.FunctionDeclarations() { + funcName := funcDecl.Identifier.Identifier + + if !strings.HasPrefix(funcName, testFunctionPrefix) { + continue + } + + if !funcDecl.ParameterList.IsEmpty() { + return nil, nil, fmt.Errorf("test functions should have no arguments") + } + + if funcDecl.ReturnTypeAnnotation != nil { + return nil, nil, fmt.Errorf("test functions should have no return values") + } + } + + script = r.replaceImports(script) + + program, err := env.ParseAndCheckProgram([]byte(script), ctx.Location, false) + if err != nil { + return nil, nil, err + } + + _, inter, err := env.Interpret( + ctx.Location, + program, + nil, + ) + + if err != nil { + return nil, nil, err + } + + return program, inter, nil +} + +func (r *TestRunner) initializeEnvironment() ( + runtime.Environment, + runtime.Context, +) { config := runtime.Config{ AccountLinkingEnabled: true, AttachmentsEnabled: true, CapabilityControllersEnabled: true, CoverageReport: r.coverageReport, } + env := runtime.NewBaseInterpreterEnvironment(config) + r.testRuntime = runtime.NewInterpreterRuntime(config) r.testFramework = NewTestFrameworkProvider( @@ -418,48 +471,16 @@ func (r *TestRunner) parseCheckAndInterpret(script string) (*interpreter.Program // returned from blockchain to the test script) env.InterpreterConfig.ContractValueHandler = r.interpreterContractValueHandler(env) - code, err := parser.ParseProgram(nil, []byte(script), parser.Config{}) - if err != nil { - panic(err) - } - - for _, funcDecl := range code.FunctionDeclarations() { - funcName := funcDecl.Identifier.Identifier - - if !strings.HasPrefix(funcName, testFunctionPrefix) { - continue - } - - if !funcDecl.ParameterList.IsEmpty() { - return nil, nil, fmt.Errorf("test functions should have no arguments") - } - - if funcDecl.ReturnTypeAnnotation != nil { - return nil, nil, fmt.Errorf("test functions should have no return values") - } - } - - script = r.replaceImports(script) - program, err := r.testRuntime.ParseAndCheckProgram([]byte(script), ctx) - if err != nil { - return nil, nil, err - } - - // Set the storage after checking, because `ParseAndCheckProgram` clears the storage. r.storage = runtime.NewStorage(ctx.Interface, nil) - env.InterpreterConfig.Storage = r.storage - _, inter, err := env.Interpret( - ctx.Location, - program, - nil, + env.Configure( + ctx.Interface, + runtime.NewCodesAndPrograms(), + r.storage, + r.coverageReport, ) - if err != nil { - return nil, nil, err - } - - return program, inter, nil + return env, ctx } func (r *TestRunner) checkerImportHandler(ctx runtime.Context) sema.ImportHandlerFunc { From 3db6e2e643573381787203ff8a9939aa6f128dea Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 4 Oct 2023 11:22:17 +0300 Subject: [PATCH 14/20] Fix contract loading error for unit tests with nested imports --- test/emulator_backend.go | 27 +++++++++--------- test/test_framework_test.go | 16 +++++++++-- test/test_runner.go | 57 ++++++++++++++++--------------------- 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/test/emulator_backend.go b/test/emulator_backend.go index 3d820755..0af29121 100644 --- a/test/emulator_backend.go +++ b/test/emulator_backend.go @@ -115,19 +115,20 @@ var commonContracts = emulator.NewCommonContracts(chain) var systemContracts = func() []common.AddressLocation { serviceAddress := chain.ServiceAddress().HexWithPrefix() contracts := map[string]string{ - "FlowServiceAccount": serviceAddress, - "FlowToken": fvm.FlowTokenAddress(chain).HexWithPrefix(), - "FungibleToken": fvm.FungibleTokenAddress(chain).HexWithPrefix(), - "FlowFees": environment.FlowFeesAddress(chain).HexWithPrefix(), - "FlowStorageFees": serviceAddress, - "FlowClusterQC": serviceAddress, - "FlowDKG": serviceAddress, - "FlowEpoch": serviceAddress, - "FlowIDTableStaking": serviceAddress, - "FlowStakingCollection": serviceAddress, - "LockedTokens": serviceAddress, - "NodeVersionBeacon": serviceAddress, - "StakingProxy": serviceAddress, + "FlowServiceAccount": serviceAddress, + "FlowToken": fvm.FlowTokenAddress(chain).HexWithPrefix(), + "FungibleToken": fvm.FungibleTokenAddress(chain).HexWithPrefix(), + "FungibleTokenMetadataViews": fvm.FungibleTokenAddress(chain).HexWithPrefix(), + "FlowFees": environment.FlowFeesAddress(chain).HexWithPrefix(), + "FlowStorageFees": serviceAddress, + "FlowClusterQC": serviceAddress, + "FlowDKG": serviceAddress, + "FlowEpoch": serviceAddress, + "FlowIDTableStaking": serviceAddress, + "FlowStakingCollection": serviceAddress, + "LockedTokens": serviceAddress, + "NodeVersionBeacon": serviceAddress, + "StakingProxy": serviceAddress, } locations := make([]common.AddressLocation, 0) diff --git a/test/test_framework_test.go b/test/test_framework_test.go index ee92294c..ff477abf 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -512,7 +512,8 @@ func TestImportContract(t *testing.T) { } pub fun test() { - Test.assertEqual(1, 1) + Test.assertEqual("Hi from BarContract", BarContract.sayHi()) + Test.assertEqual("Hi from BarContract", FooContract.sayHi()) } ` @@ -521,12 +522,20 @@ func TestImportContract(t *testing.T) { pub contract FooContract { init() {} + + pub fun sayHi(): String { + return BarContract.sayHi() + } } ` const barContract = ` pub contract BarContract { init() {} + + pub fun sayHi(): String { + return "Hi from BarContract" + } } ` @@ -572,8 +581,9 @@ func TestImportContract(t *testing.T) { WithContracts(contracts). WithFileResolver(fileResolver) - _, err := runner.RunTest(code, "test") + result, err := runner.RunTest(code, "test") require.NoError(t, err) + require.NoError(t, result.Error) }) t.Run("undeployed contract", func(t *testing.T) { @@ -3550,6 +3560,7 @@ func TestCoverageReportForUnitTests(t *testing.T) { "A.0000000000000001.FlowClusterQC", "A.0000000000000001.NFTStorefront", "A.0000000000000002.FungibleToken", + "A.0000000000000002.FungibleTokenMetadataViews", "A.0000000000000001.NodeVersionBeacon", "A.0000000000000003.FlowToken", "A.0000000000000001.FlowEpoch", @@ -3766,6 +3777,7 @@ func TestCoverageReportForIntegrationTests(t *testing.T) { []string{ "A.0000000000000003.FlowToken", "A.0000000000000002.FungibleToken", + "A.0000000000000002.FungibleTokenMetadataViews", "A.0000000000000004.FlowFees", "A.0000000000000001.FlowStorageFees", "A.0000000000000001.FlowServiceAccount", diff --git a/test/test_runner.go b/test/test_runner.go index f6129aa6..eed5d12e 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -140,8 +140,6 @@ type TestRunner struct { testFramework stdlib.TestFramework backend *EmulatorBackend - - storage *runtime.Storage } func NewTestRunner() *TestRunner { @@ -471,12 +469,10 @@ func (r *TestRunner) initializeEnvironment() ( // returned from blockchain to the test script) env.InterpreterConfig.ContractValueHandler = r.interpreterContractValueHandler(env) - r.storage = runtime.NewStorage(ctx.Interface, nil) - env.Configure( ctx.Interface, runtime.NewCodesAndPrograms(), - r.storage, + runtime.NewStorage(ctx.Interface, nil), r.coverageReport, ) @@ -584,7 +580,11 @@ func (r *TestRunner) interpreterContractValueHandler( switch location := compositeType.Location.(type) { case common.AddressLocation: - storageMap := r.storage.GetStorageMap( + storage := runtime.NewStorage( + r.backend.blockchain.NewScriptEnvironment(), + nil, + ) + storageMap := storage.GetStorageMap( location.Address, runtime.StorageDomainContract, false, @@ -704,7 +704,12 @@ func (r *TestRunner) parseAndCheckImport( default: addressLoc, ok := importedLocation.(common.AddressLocation) - if ok { + if !ok { + return nil, fmt.Errorf("unable to import location: %s", importedLocation) + } + + var code []byte + if _, found := baseContracts()[addressLoc.Name]; found { // System-defined contracts are obtained from // the blockchain. account, err := r.backend.blockchain.GetAccount( @@ -713,43 +718,31 @@ func (r *TestRunner) parseAndCheckImport( if err != nil { return nil, err } - code := account.Contracts[addressLoc.Name] - program, err := env.ParseAndCheckProgram( - code, addressLoc, true, - ) + code = account.Contracts[addressLoc.Name] + } else if _, found := r.contracts[addressLoc.Name]; found { + contract, err := r.importResolver(addressLoc) if err != nil { return nil, err } - - return sema.ElaborationImport{ - Elaboration: program.Elaboration, - }, nil + code = []byte(contract) } - stringLocation, ok := importedLocation.(common.StringLocation) - if ok { - code, err := r.importResolver(stringLocation) - if err != nil { - return nil, err - } - program, err := env.ParseAndCheckProgram( - []byte(code), stringLocation, true, - ) - if err != nil { - return nil, err - } - - return sema.ElaborationImport{ - Elaboration: program.Elaboration, - }, nil + program, err := env.ParseAndCheckProgram( + code, addressLoc, true, + ) + if err != nil { + return nil, err } - return nil, fmt.Errorf("unable to import location: %s", importedLocation) + return sema.ElaborationImport{ + Elaboration: program.Elaboration, + }, nil } } env.CheckerConfig.ContractValueHandler = contractValueHandler + code = r.replaceImports(code) program, err := r.testRuntime.ParseAndCheckProgram([]byte(code), ctx) if err != nil { From fda31d86707d91c74db4f7766b6c926538ec9083 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 4 Oct 2023 11:36:47 +0300 Subject: [PATCH 15/20] Add blockchain helpers for script/transaction execution --- test/blockchain_helpers.cdc | 32 ++++++++++++ test/test_framework_test.go | 98 +++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/test/blockchain_helpers.cdc b/test/blockchain_helpers.cdc index c6d74369..fa761ec9 100644 --- a/test/blockchain_helpers.cdc +++ b/test/blockchain_helpers.cdc @@ -65,6 +65,38 @@ fun burnFlow( return Test.executeTransaction(tx) } +/// Executes a script and returns the script return value and the status. +/// `returnValue` field of the result will be `nil` if the script failed. +/// +access(all) +fun executeScript( + _ path: String, + _ arguments: [AnyStruct] +): Test.ScriptResult { + let script = Test.readFile(path) + return Test.executeScript(script, arguments) +} + +/// Executes a given transaction, commits the current block +/// and returns the result of transaction execution. +/// +access(all) +fun executeTransaction( + _ path: String, + _ arguments: [AnyStruct], + _ account: Test.Account +): Test.TransactionResult { + let code = Test.readFile(path) + let tx = Test.Transaction( + code: code, + authorizers: [account.address], + signers: [account], + arguments: arguments + ) + + return Test.executeTransaction(tx) +} + /// Reads the code for the script/transaction with the given /// file name and returns its content as a String. /// diff --git a/test/test_framework_test.go b/test/test_framework_test.go index ff477abf..0773917e 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -3273,6 +3273,104 @@ func TestBurnFlow(t *testing.T) { require.NoError(t, result.Error) } +func TestExecuteScriptHelper(t *testing.T) { + t.Parallel() + + const code = ` + import Test + import BlockchainHelpers + + pub fun test() { + let scriptResult = executeScript("add_integers.cdc", []) + + Test.expect(scriptResult, Test.beSucceeded()) + Test.assertEqual(5, scriptResult.returnValue! as! Int) + } + ` + + const script = ` + pub fun main(): Int { + return 2 + 3 + } + ` + + fileResolver := func(path string) (string, error) { + switch path { + case "add_integers.cdc": + return script, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + runner := NewTestRunner().WithFileResolver(fileResolver) + result, err := runner.RunTest(code, "test") + require.NoError(t, err) + require.NoError(t, result.Error) +} + +func TestExecuteTransactionHelper(t *testing.T) { + t.Parallel() + + const code = ` + import Test + import BlockchainHelpers + + pub fun test() { + let account = Test.createAccount() + let txResult = executeTransaction( + "setup_example_nft_collection.cdc", + [], + account + ) + + Test.expect(txResult, Test.beSucceeded()) + } + ` + + const transaction = ` + import "NonFungibleToken" + import "ExampleNFT" + import "MetadataViews" + + transaction { + + prepare(signer: AuthAccount) { + // Return early if the account already has a collection + if signer.borrow<&ExampleNFT.Collection>(from: ExampleNFT.CollectionStoragePath) != nil { + return + } + + // Create a new empty collection + let collection <- ExampleNFT.createEmptyCollection() + + // save it to the account + signer.save(<-collection, to: ExampleNFT.CollectionStoragePath) + + // create a public capability for the collection + signer.link<&{NonFungibleToken.CollectionPublic, ExampleNFT.ExampleNFTCollectionPublic, MetadataViews.ResolverCollection}>( + ExampleNFT.CollectionPublicPath, + target: ExampleNFT.CollectionStoragePath + ) + } + } + ` + + fileResolver := func(path string) (string, error) { + switch path { + case "setup_example_nft_collection.cdc": + return transaction, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + runner := NewTestRunner().WithFileResolver(fileResolver) + result, err := runner.RunTest(code, "test") + require.NoError(t, err) + require.NoError(t, result.Error) +} + func TestServiceAccount(t *testing.T) { t.Parallel() From c1e14d28046543ff55a196d7b35d3970b8ffad19 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 4 Oct 2023 14:09:54 +0300 Subject: [PATCH 16/20] Add test case with multiple imports in the same test file --- test/test_framework_test.go | 99 ++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 0773917e..33ee2266 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -493,8 +493,6 @@ func TestImportContract(t *testing.T) { import BarContract from "./BarContract" import FooContract from "./FooContract" - pub let account = Test.getAccount(0x0000000000000005) - pub fun setup() { var err = Test.deployContract( name: "BarContract", @@ -586,6 +584,103 @@ func TestImportContract(t *testing.T) { require.NoError(t, result.Error) }) + t.Run("multiple imports", func(t *testing.T) { + t.Parallel() + + const code = ` + import Test + import FooContract from "./FooContract" + import BarContract from "./BarContract" + + pub fun setup() { + var err = Test.deployContract( + name: "BarContract", + path: "./BarContract", + arguments: [] + ) + Test.expect(err, Test.beNil()) + + err = Test.deployContract( + name: "FooContract", + path: "./FooContract", + arguments: [] + ) + Test.expect(err, Test.beNil()) + } + + pub fun test() { + Test.assertEqual("Hi from BarContract", BarContract.sayHi()) + Test.assertEqual("Hi from FooContract", FooContract.sayHi()) + } + ` + + const fooContract = ` + pub contract FooContract { + init() {} + + pub fun sayHi(): String { + return "Hi from FooContract" + } + } + ` + + const barContract = ` + pub contract BarContract { + init() {} + + pub fun sayHi(): String { + return "Hi from BarContract" + } + } + ` + + importResolver := func(location common.Location) (string, error) { + switch location := location.(type) { + case common.AddressLocation: + if location.Name == "FooContract" { + return fooContract, nil + } + if location.Name == "BarContract" { + return barContract, nil + } + case common.StringLocation: + if location == "./FooContract" { + return fooContract, nil + } + if location == "./BarContract" { + return barContract, nil + } + } + + return "", fmt.Errorf("unsupported import %s", location) + } + + fileResolver := func(path string) (string, error) { + switch path { + case "./FooContract": + return fooContract, nil + case "./BarContract": + return barContract, nil + default: + return "", fmt.Errorf("cannot find file path: %s", path) + } + } + + contracts := map[string]common.Address{ + "BarContract": {0, 0, 0, 0, 0, 0, 0, 5}, + "FooContract": {0, 0, 0, 0, 0, 0, 0, 5}, + } + + runner := NewTestRunner(). + WithImportResolver(importResolver). + WithContracts(contracts). + WithFileResolver(fileResolver) + + result, err := runner.RunTest(code, "test") + require.NoError(t, err) + require.NoError(t, result.Error) + }) + t.Run("undeployed contract", func(t *testing.T) { t.Parallel() From b3d0a35d98ce3fce4f22e30078b910437f761479 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Fri, 6 Oct 2023 13:33:34 +0300 Subject: [PATCH 17/20] Make sure to update the interpreter's storage to reflect deployment changes --- test/test_framework_test.go | 9 +++++++-- test/test_runner.go | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/test_framework_test.go b/test/test_framework_test.go index 33ee2266..0b16bec1 100644 --- a/test/test_framework_test.go +++ b/test/test_framework_test.go @@ -609,14 +609,19 @@ func TestImportContract(t *testing.T) { } pub fun test() { - Test.assertEqual("Hi from BarContract", BarContract.sayHi()) Test.assertEqual("Hi from FooContract", FooContract.sayHi()) + Test.assertEqual("Hi from BarContract", BarContract.sayHi()) + Test.assertEqual(3, FooContract.numbers.length) } ` const fooContract = ` pub contract FooContract { - init() {} + pub let numbers: {Int: String} + + init() { + self.numbers = {1: "one", 2: "two", 3: "three"} + } pub fun sayHi(): String { return "Hi from FooContract" diff --git a/test/test_runner.go b/test/test_runner.go index eed5d12e..9f445a7f 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -584,6 +584,9 @@ func (r *TestRunner) interpreterContractValueHandler( r.backend.blockchain.NewScriptEnvironment(), nil, ) + // Update the storage to reflect the changes + // from deployments in setup() function. + inter.SharedState.Config.Storage = storage storageMap := storage.GetStorageMap( location.Address, runtime.StorageDomainContract, From 0cce6b2b47f11ddde4038f1b5420908844535505 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 9 Oct 2023 14:18:44 +0300 Subject: [PATCH 18/20] Bump onflow/cadence dependency to v0.42.0 --- test/go.mod | 2 +- test/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/go.mod b/test/go.mod index 3fdb0c73..c770a0db 100644 --- a/test/go.mod +++ b/test/go.mod @@ -3,7 +3,7 @@ module github.com/onflow/cadence-tools/test go 1.18 require ( - github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 + github.com/onflow/cadence v0.42.0 github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 github.com/onflow/flow-go-sdk v0.41.10 diff --git a/test/go.sum b/test/go.sum index 87141062..99bf95c2 100644 --- a/test/go.sum +++ b/test/go.sum @@ -498,8 +498,8 @@ github.com/onflow/atree v0.1.0-beta1.0.20211027184039-559ee654ece9/go.mod h1:+6x github.com/onflow/atree v0.6.0 h1:j7nQ2r8npznx4NX39zPpBYHmdy45f4xwoi+dm37Jk7c= github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVFi0tc= github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= -github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44 h1:olRNAL60z/xUq+IWc9tUZdciTHNgfFDinqyE++oGZ9A= -github.com/onflow/cadence v0.41.2-0.20230927235343-1956c2ec9f44/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= +github.com/onflow/cadence v0.42.0 h1:XatyCy1pZu10x+JouRU6cZ9A50dF3uM+ubqYUER1/Vk= +github.com/onflow/cadence v0.42.0/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20230703193002-53362441b57d h1:B7PdhdUNkve5MVrekWDuQf84XsGBxNZ/D3x+QQ8XeVs= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20230703193002-53362441b57d/go.mod h1:xAiV/7TKhw863r6iO3CS5RnQ4F+pBY1TxD272BsILlo= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.3 h1:X25A1dNajNUtE+KoV76wQ6BR6qI7G65vuuRXxDDqX7E= From 7c52b63dbfc0feea2f2d2ec12f9a39f78aea4626 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 11 Oct 2023 15:54:53 +0300 Subject: [PATCH 19/20] Update onflow/flow-go module to latest master commit with cadence v0.42.0 --- test/go.mod | 5 +++-- test/go.sum | 63 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/test/go.mod b/test/go.mod index c770a0db..bfbe6f90 100644 --- a/test/go.mod +++ b/test/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/onflow/cadence v0.42.0 github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 - github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 + github.com/onflow/flow-go v0.32.1-0.20231009165946-259992f09ef0 github.com/onflow/flow-go-sdk v0.41.10 github.com/rs/zerolog v1.29.0 github.com/stretchr/testify v1.8.4 @@ -44,6 +44,7 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/ipfs/bbloom v0.0.4 // indirect @@ -89,7 +90,7 @@ require ( github.com/onflow/flow-ft/lib/go/contracts v0.7.0 // indirect github.com/onflow/flow-go/crypto v0.24.9 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect - github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230628215638-83439d22e0ce // indirect + github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9 // indirect github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead // indirect github.com/onflow/sdks v0.5.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect diff --git a/test/go.sum b/test/go.sum index 99bf95c2..e3bbbcac 100644 --- a/test/go.sum +++ b/test/go.sum @@ -62,6 +62,7 @@ github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6L github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI= github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= @@ -121,14 +122,23 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= +github.com/cockroachdb/pebble v0.0.0-20230829171545-74d4bb649d92 h1:uGCVnrAKqpaPEyFD8CK50oEy5jBfwgy1ZyfBUwlh1PM= +github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw= +github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -138,6 +148,7 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= @@ -155,6 +166,7 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cu github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -163,6 +175,7 @@ github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt github.com/ef-ds/deque v1.0.4 h1:iFAZNmveMT9WERAkqLJ+oaABF9AcVQ5AjXem/hroniI= github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg= github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= +github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -177,7 +190,9 @@ github.com/ethereum/go-ethereum v1.9.13 h1:rOPqjSngvs1VSYH2H+PMPiWt4VEulvNRbFgqi github.com/ethereum/go-ethereum v1.9.13/go.mod h1:qwN9d1GLyDh0N7Ab8bMGd0H9knaji2jOBm2RrMGjXls= github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -188,6 +203,7 @@ github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c/go.mod h1:TA1x github.com/fxamacker/circlehash v0.1.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA= github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= @@ -207,12 +223,17 @@ github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-test/deep v1.0.5/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -275,6 +296,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -307,6 +329,7 @@ github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0 github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -326,10 +349,12 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru/v2 v2.0.2 h1:Dwmkdr5Nc/oBiXgJS3CDHNhJtIHkuZ3DZF5twqnfBdU= +github.com/hashicorp/golang-lru/v2 v2.0.2/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag= +github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -365,8 +390,11 @@ github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= +github.com/ipld/go-ipld-prime v0.20.0 h1:Ud3VwE9ClxpO2LkCYP7vWPc0Fo+dYdYzgxUJZ3uRG4g= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= +github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -396,6 +424,7 @@ github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuOb github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -408,15 +437,24 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/libp2p/go-addr-util v0.1.0 h1:acKsntI33w2bTU7tC9a0SaPimJGfSI0bFKC18ChxeVI= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= +github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= github.com/libp2p/go-libp2p v0.28.1 h1:YurK+ZAI6cKfASLJBVFkpVBdl3wGhFi6fusOt725ii8= github.com/libp2p/go-libp2p v0.28.1/go.mod h1:s3Xabc9LSwOcnv9UD4nORnXKTsWkPMkIMB/JIGXVnzk= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= +github.com/libp2p/go-libp2p-kad-dht v0.24.2 h1:zd7myKBKCmtZBhI3I0zm8xBkb28v3gmSEtQfBdAdFwc= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-pubsub v0.9.3 h1:ihcz9oIBMaCK9kcx+yHWm3mLAFBMAUsM4ux42aikDxo= +github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= +github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= +github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= +github.com/libp2p/go-reuseport v0.3.0 h1:iiZslO5byUYZEg9iCwJGf5h+sf1Agmqx2V2FDjPyvUw= +github.com/libp2p/go-yamux/v4 v4.0.0 h1:+Y80dV2Yx/kv7Y7JKu0LECyVdMXm1VUoko+VQ9rBfZQ= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= @@ -425,6 +463,7 @@ github.com/logrusorgru/aurora/v4 v4.0.0/go.mod h1:lP0iIa2nrnT/qoFXcOZSrZQpJ1o6n2 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -452,6 +491,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= @@ -474,6 +515,7 @@ github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= +github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= @@ -508,8 +550,8 @@ github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378 h1:H7NfRcY github.com/onflow/flow-emulator v0.54.2-0.20230928194031-75caeb6a3378/go.mod h1:cPKNx2eaxUDtXNHN9nnrt/qydWUHNQRTa/9QnsaCSpo= github.com/onflow/flow-ft/lib/go/contracts v0.7.0 h1:XEKE6qJUw3luhsYmIOteXP53gtxNxrwTohgxJXCYqBE= github.com/onflow/flow-ft/lib/go/contracts v0.7.0/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU= -github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58 h1:SJS/WqckE6lcXmCOL/7Gp39zY66mCcEhy9xfmyomKrw= -github.com/onflow/flow-go v0.31.1-0.20230901090702-eeeef3a7bd58/go.mod h1:PdmGmlNDu9HOhg31NYAKLrIhmuTvFDgCS56CTs0af9Y= +github.com/onflow/flow-go v0.32.1-0.20231009165946-259992f09ef0 h1:F65hcC5jGrLh95UMZiS/CHnrkiP/INTb1A+MyOsDA+k= +github.com/onflow/flow-go v0.32.1-0.20231009165946-259992f09ef0/go.mod h1:zR/4oxlMRzUxNgSPLhjzLI989x3F7dkswxSsE9t7VLQ= github.com/onflow/flow-go-sdk v0.24.0/go.mod h1:IoptMLPyFXWvyd9yYA6/4EmSeeozl6nJoIv4FaEMg74= github.com/onflow/flow-go-sdk v0.41.10 h1:Cio6GJhtx532TUY+cqrqWglD5sZCXkWeM5QvaRha3p4= github.com/onflow/flow-go-sdk v0.41.10/go.mod h1:0a0LiQFbFt8RW/ptoMUU7YkvW9ArVcbjLE0XS78uz1E= @@ -519,8 +561,8 @@ github.com/onflow/flow-go/crypto v0.24.9/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7 github.com/onflow/flow-nft/lib/go/contracts v1.1.0 h1:rhUDeD27jhLwOqQKI/23008CYfnqXErrJvc4EFRP2a0= github.com/onflow/flow-nft/lib/go/contracts v1.1.0/go.mod h1:YsvzYng4htDgRB9sa9jxdwoTuuhjK8WYWXTyLkIigZY= github.com/onflow/flow/protobuf/go/flow v0.2.2/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8= -github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230628215638-83439d22e0ce h1:YQKijiQaq8SF1ayNqp3VVcwbBGXSnuHNHq4GQmVGybE= -github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230628215638-83439d22e0ce/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9 h1:IGDANryEVnuVAlDZDzNLMMUui9lbwS04KE70C0HXkFw= +github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230915140723-432828f7afb9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead h1:2j1Unqs76Z1b95Gu4C3Y28hzNUHBix7wL490e61SMSw= github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207cead/go.mod h1:E3ScfQb5XcWJCIAdtIeEnr5i5l2y60GT0BTXeIHseWg= github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8= @@ -529,8 +571,10 @@ github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d h1:gAEqYPn3DS83rHIKEpsa github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= @@ -552,6 +596,7 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= @@ -575,6 +620,12 @@ github.com/psiemens/graceland v1.0.0 h1:L580AVV4Q2XLcPpmvxJRH9UpEAYr/eu2jBKmMglh github.com/psiemens/graceland v1.0.0/go.mod h1:1Tof+vt1LbmcZFE0lzgdwMN0QBymAChG3FRgDx8XisU= github.com/psiemens/sconfig v0.1.0 h1:xfWqW+TRpih7mXZIqKYTmpRhlZLQ1kbxV8EjllPv76s= github.com/psiemens/sconfig v0.1.0/go.mod h1:+MLKqdledP/8G3rOBpknbLh0IclCf4WneJUtS26JB2U= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= +github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= +github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= +github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2EptUrfOPWU= +github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= @@ -669,6 +720,7 @@ github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0 github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= @@ -695,6 +747,7 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= @@ -717,6 +770,8 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/dig v1.17.0 h1:5Chju+tUvcC+N7N6EV08BJz41UZuO3BmHcN4A287ZLI= +go.uber.org/fx v1.19.2 h1:SyFgYQFr1Wl0AYstE8vyYIzP4bFz2URrScjwC4cwUvY= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= From 285769e6ce2bf37c90ad4c5461d63aaef792de94 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Thu, 12 Oct 2023 16:36:51 -0700 Subject: [PATCH 20/20] Add todo for the tech-debt --- test/test_runner.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_runner.go b/test/test_runner.go index 9f445a7f..e3b0c556 100644 --- a/test/test_runner.go +++ b/test/test_runner.go @@ -374,6 +374,7 @@ func (r *TestRunner) parseCheckAndInterpret(script string) ( *interpreter.Interpreter, error, ) { + // TODO: move this eventually to the `NewTestRunner` env, ctx := r.initializeEnvironment() astProgram, err := parser.ParseProgram(nil, []byte(script), parser.Config{})