diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c09a63..b6c1525 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,27 +8,7 @@ jobs: tests: runs-on: ubuntu-18.04 steps: - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: Checkout candid repo - uses: actions/checkout@v2 - with: - repository: dfinity/candid - - name: Install candid tools - run: | - cd tools/didc - cargo install --root /home/runner --path . - cd .. - cd candiff - cargo install --root /home/runner --path . - cd ../.. - echo "::add-path::/home/runner/bin" - uses: actions/checkout@v2 - - name: "didc help (sanity check)" - run: didc --help - - name: "candiff help (sanity check)" - run: candiff --help - name: "install dfx" run: | wget https://sdk.dfinity.org/install.sh @@ -39,5 +19,13 @@ jobs: run: dfx cache install - name: "install vessel" run: wget --output-document /home/runner/bin/vessel https://github.com/kritzcreek/vessel/releases/download/v0.4.1/vessel-linux64 && chmod +x /home/runner/bin/vessel + - name: "install candid tool" + run: wget --output-document /home/runner/bin/candiff https://github.com/dfinity/candid/releases/download/2020-08-18/candiff-linux64 && chmod +x /home/runner/bin/candiff + - name: "candiff help (sanity check)" + run: candiff --help + - name: "install didc tool" + run: wget --output-document /home/runner/bin/didc https://github.com/dfinity/candid/releases/download/2020-08-18/didc-linux64 && chmod +x /home/runner/bin/didc + - name: "didc help (sanity check)" + run: didc --help - name: "test" run: ./test.sh \ No newline at end of file diff --git a/test.sh b/test.sh index 7335575..d408008 100755 --- a/test.sh +++ b/test.sh @@ -20,7 +20,30 @@ echo == Test BigMap service. echo dfx canister install BigMapPutGet + LOOP="(true)"; while [ "$LOOP" == "(true)" ]; do LOOP=$(dfx canister call BigMapPutGet doNextCall) done + +dfx canister call BigMapPutGet getFullLog --output raw > BigMapPutGet.raw + +echo BEGIN BigMapPutGet.raw +cat BigMapPutGet.raw +echo END BigMapPutGet.raw + +echo BEGIN 'didc decode `cat BigMapPutGet.raw` > BigMapPutGet.log' +didc decode `cat BigMapPutGet.raw` -d .dfx/local/canisters/BigMapPutGet/BigMapPutGet.did -m getFullLog > BigMapPutGet.log +echo END 'didc decode `cat BigMapPutGet.raw`' + +echo BEGIN "BigMapPutGet.log (latest-captured log)" +cat BigMapPutGet.log +echo END "BigMapPutGet.log" + +echo BEGIN "test/BigMapPutGet.log (expected log)" +cat test/BigMapPutGet.log +echo END "test/BigMapPutGet.log" + +echo BEGIN "candiff compares a expected log (left) and latest captured log (right):" +candiff diff "`cat test/BigMapPutGet.log`" "`cat BigMapPutGet.log`" +echo END candiff comparison. diff --git a/test/BigMapPutGet.log b/test/BigMapPutGet.log new file mode 100644 index 0000000..50b2b8c --- /dev/null +++ b/test/BigMapPutGet.log @@ -0,0 +1 @@ +(vec { record { 0 = variant { put = record { 0 = vec { 0; }; 1 = vec { 0; }; } }; 1 = variant { ok = variant { unit = null } }; }; record { 0 = variant { get = vec { 0; } }; 1 = variant { ok = variant { opt = variant { nat = 0 } } }; }; record { 0 = variant { put = record { 0 = vec { 0; }; 1 = vec { 0; }; } }; 1 = variant { ok = variant { unit = null } }; }; record { 0 = variant { put = record { 0 = vec { 1; }; 1 = vec { 1; }; } }; 1 = variant { ok = variant { unit = null } }; }; record { 0 = variant { get = vec { 0; } }; 1 = variant { ok = variant { opt = variant { nat = 0 } } }; }; record { 0 = variant { get = vec { 1; } }; 1 = variant { ok = variant { opt = variant { nat = 1 } } }; }; }) diff --git a/test/BigMapPutGet.mo b/test/BigMapPutGet.mo index 594b2db..28c6151 100644 --- a/test/BigMapPutGet.mo +++ b/test/BigMapPutGet.mo @@ -2,6 +2,7 @@ import Prim "mo:prim"; import BigMap "canister:BigMap"; import Iter "mo:base/Iter"; import Debug "mo:base/Debug"; +import Buffer "mo:base/Buffer"; import TestBatch "../src/Batch"; import TestTypes "../src/Types"; @@ -43,7 +44,8 @@ actor { }; // some defaults - var batch : TestBatch.Batch = newBatches([0, 1, 2, 4, 8 + var batch : TestBatch.Batch = newBatches([0, 1 + //,2, 4, 8 -- TEMP -- make this faster for CI iteration... //,128 -- takes an hour or so ]); @@ -73,12 +75,23 @@ actor { Debug.print ("doNextCall - result = " # (debug_show r)); Debug.print "doNextCall - saving result..."; batch.saveResult(r); + callLog.add((c, r)); Debug.print "doNextCall end"; true } } }; + public type CallReq = TestTypes.CallReq; + public type CallRes = TestTypes.Res; + public type CallLog = [(CallReq, CallRes)]; + + var callLog : Buffer.Buffer<(CallReq, CallRes)> = Buffer.Buffer(0); + + public func getFullLog () : async CallLog { + callLog.toArray() + }; + // Bonus: // For testing in an open, interactive world: // Use this to add other tests not-yet expressed above!