From 9c0eebd9a1a37d90845bb8d1bd4fe6305ac5ab23 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Wed, 18 Oct 2023 17:20:21 +0200 Subject: [PATCH 1/3] tests: alliance module --- Makefile | 5 - integration-tests/jest.config.js | 1 + integration-tests/package-lock.json | 204 +++++------ integration-tests/package.json | 2 +- integration-tests/src/helpers/const.ts | 2 + integration-tests/src/helpers/mnemonics.ts | 7 +- .../src/modules/alliance.test.ts | 346 ++++++++++++++++++ scripts/tests/alliance/delegate.sh | 96 ----- scripts/tests/init-test-framework.sh | 4 +- 9 files changed, 457 insertions(+), 210 deletions(-) create mode 100644 integration-tests/src/modules/alliance.test.ts delete mode 100755 scripts/tests/alliance/delegate.sh diff --git a/Makefile b/Makefile index 32b599a5..026167c5 100644 --- a/Makefile +++ b/Makefile @@ -206,7 +206,6 @@ integration-test-all: init-test-framework \ test-ica \ test-ibc-hooks \ test-vesting-accounts \ - test-alliance \ test-tokenfactory init-test-framework: clean-testing-data install @@ -225,10 +224,6 @@ test-ibc-hooks: @echo "Testing ibc hooks..." ./scripts/tests/ibc-hooks/increment.sh -test-alliance: - @echo "Testing alliance module..." - ./scripts/tests/alliance/delegate.sh - test-tokenfactory: @echo "Testing tokenfactory..." ./scripts/tests/tokenfactory/tokenfactory.sh diff --git a/integration-tests/jest.config.js b/integration-tests/jest.config.js index 23774576..55a51a90 100644 --- a/integration-tests/jest.config.js +++ b/integration-tests/jest.config.js @@ -4,4 +4,5 @@ module.exports = { testEnvironment: 'node', testMatch: ['**/*.test.ts'], verbose: true, + testTimeout: 30000, }; \ No newline at end of file diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 4137b4a4..6d7427ed 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.6.2", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^1.1.3", + "@terra-money/feather.js": "^1.2.1", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1704,9 +1704,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", - "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.1.3.tgz", - "integrity": "sha512-4x/ITuWArHw6Ge4DmeuRQ8hRUp8C94jhfiGyLsCjSBHErGYrmJcfYINDGs6vfqxySaY7DA2d5BbXMrd6iLV5yw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.2.1.tgz", + "integrity": "sha512-OyXkWriNwb0lCF45eMmtjdOPEmfGKJxgGSnxpM7VxD0Vqr1qqtlcYyQG9wOHXNQrExvZv+uo922B2ZA4S77HsQ==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -1866,9 +1866,9 @@ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, "node_modules/@types/babel__core": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.2.tgz", - "integrity": "sha512-pNpr1T1xLUc2l3xJKuPtsEky3ybxN3m4fJkknfIpTCTfIZCDW57oAg+EfCgIIp2rvCe0Wn++/FfodDS4YXxBwA==", + "version": "7.20.3", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.3.tgz", + "integrity": "sha512-54fjTSeSHwfan8AyHWrKbfBWiEUrNTZsUwPTDSNaaP1QDQIZbeNUg3a59E9D+375MzUw/x1vx2/0F5LBz+AeYA==", "dev": true, "dependencies": { "@babel/parser": "^7.20.7", @@ -1879,18 +1879,18 @@ } }, "node_modules/@types/babel__generator": { - "version": "7.6.5", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.5.tgz", - "integrity": "sha512-h9yIuWbJKdOPLJTbmSpPzkF67e659PbQDba7ifWm5BJ8xTv+sDmS7rFmywkWOvXedGTivCdeGSIIX8WLcRTz8w==", + "version": "7.6.6", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.6.tgz", + "integrity": "sha512-66BXMKb/sUWbMdBNdMvajU7i/44RkrA3z/Yt1c7R5xejt8qh84iU54yUWCtm0QwGJlDcf/gg4zd/x4mpLAlb/w==", "dev": true, "dependencies": { "@babel/types": "^7.0.0" } }, "node_modules/@types/babel__template": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.2.tgz", - "integrity": "sha512-/AVzPICMhMOMYoSx9MoKpGDKdBRsIXMNByh1PXSZoa+v6ZoLa8xxtsT/uLQ/NJm0XVAWl/BvId4MlDeXJaeIZQ==", + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.3.tgz", + "integrity": "sha512-ciwyCLeuRfxboZ4isgdNZi/tkt06m8Tw6uGbBSBgWrnnZGNXiEyM27xc/PjXGQLqlZ6ylbgHMnm7ccF9tCkOeQ==", "dev": true, "dependencies": { "@babel/parser": "^7.1.0", @@ -1898,51 +1898,51 @@ } }, "node_modules/@types/babel__traverse": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.2.tgz", - "integrity": "sha512-ojlGK1Hsfce93J0+kn3H5R73elidKUaZonirN33GSmgTUMpzI/MIFfSpF3haANe3G1bEBS9/9/QEqwTzwqFsKw==", + "version": "7.20.3", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.3.tgz", + "integrity": "sha512-Lsh766rGEFbaxMIDH7Qa+Yha8cMVI3qAK6CHt3OR0YfxOIn5Z54iHiyDRycHrBqeIiqGa20Kpsv1cavfBKkRSw==", "dev": true, "dependencies": { "@babel/types": "^7.20.7" } }, "node_modules/@types/graceful-fs": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.7.tgz", - "integrity": "sha512-MhzcwU8aUygZroVwL2jeYk6JisJrPl/oov/gsgGCue9mkgl9wjGbzReYQClxiUgFDnib9FuHqTndccKeZKxTRw==", + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.8.tgz", + "integrity": "sha512-NhRH7YzWq8WiNKVavKPBmtLYZHxNY19Hh+az28O/phfp68CF45pMFud+ZzJ8ewnxnC5smIdF3dqFeiSUQ5I+pw==", "dev": true, "dependencies": { "@types/node": "*" } }, "node_modules/@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", + "integrity": "sha512-zONci81DZYCZjiLe0r6equvZut0b+dBRPBN5kBDjsONnutYNtJMoWQ9uR2RkL1gLG9NMTzvf+29e5RFfPbeKhQ==", "dev": true }, "node_modules/@types/istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-gPQuzaPR5h/djlAv2apEG1HVOyj1IUs7GpfMZixU0/0KXT3pm64ylHuMUI1/Akh+sq/iikxg6Z2j+fcMDXaaTQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.2.tgz", + "integrity": "sha512-8toY6FgdltSdONav1XtUHl4LN1yTmLza+EuDazb/fEmRNCwjyqNVIQWs2IfC74IqjHkREs/nQ2FWq5kZU9IC0w==", "dev": true, "dependencies": { "@types/istanbul-lib-coverage": "*" } }, "node_modules/@types/istanbul-reports": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.2.tgz", - "integrity": "sha512-kv43F9eb3Lhj+lr/Hn6OcLCs/sSM8bt+fIaP11rCYngfV6NVjzWXJ17owQtDQTL9tQ8WSLUrGsSJ6rJz0F1w1A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.3.tgz", + "integrity": "sha512-1nESsePMBlf0RPRffLZi5ujYh7IH1BWL4y9pr+Bn3cJBdxz+RTP8bUFljLz9HvzhhOSWKdyBZ4DIivdL6rvgZg==", "dev": true, "dependencies": { "@types/istanbul-lib-report": "*" } }, "node_modules/@types/jest": { - "version": "29.5.5", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.5.tgz", - "integrity": "sha512-ebylz2hnsWR9mYvmBFbXJXr+33UPc4+ZdxyDXh5w0FlPBTfCVN3wPL+kuOiQt3xvrK419v7XWeAs+AeOksafXg==", + "version": "29.5.6", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.6.tgz", + "integrity": "sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -1955,12 +1955,9 @@ "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "node_modules/@types/node": { - "version": "20.8.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.6.tgz", - "integrity": "sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==", - "dependencies": { - "undici-types": "~5.25.1" - } + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" }, "node_modules/@types/stack-utils": { "version": "2.0.1", @@ -2271,11 +2268,6 @@ "node": ">=6.0.0" } }, - "node_modules/bip32/node_modules/@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" - }, "node_modules/bip39": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", @@ -2527,9 +2519,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001549", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz", - "integrity": "sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA==", + "version": "1.0.30001550", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001550.tgz", + "integrity": "sha512-p82WjBYIypO0ukTsd/FG3Xxs+4tFeaY9pfT4amQL8KWtYH7H9nYwReGAbMTJ0hsmRO8IfDtsS6p3ZWj8+1c2RQ==", "dev": true, "funding": [ { @@ -2891,9 +2883,9 @@ "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, "node_modules/electron-to-chromium": { - "version": "1.4.554", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.554.tgz", - "integrity": "sha512-Q0umzPJjfBrrj8unkONTgbKQXzXRrH7sVV7D9ea2yBV3Oaogz991yhbpfvo2LMNkJItmruXTEzVpP9cp7vaIiQ==", + "version": "1.4.557", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.557.tgz", + "integrity": "sha512-6x0zsxyMXpnMJnHrondrD3SuAeKcwij9S+83j2qHAQPXbGTDDfgImzzwgGlzrIcXbHQ42tkG4qA6U860cImNhw==", "dev": true }, "node_modules/elliptic": { @@ -4950,6 +4942,14 @@ "pbts": "bin/pbts" } }, + "node_modules/protobufjs/node_modules/@types/node": { + "version": "20.8.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", + "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", + "dependencies": { + "undici-types": "~5.25.1" + } + }, "node_modules/protobufjs/node_modules/long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", @@ -6915,9 +6915,9 @@ "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", - "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", "dev": true, "requires": { "@jridgewell/resolve-uri": "^3.1.0", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.1.3.tgz", - "integrity": "sha512-4x/ITuWArHw6Ge4DmeuRQ8hRUp8C94jhfiGyLsCjSBHErGYrmJcfYINDGs6vfqxySaY7DA2d5BbXMrd6iLV5yw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.2.1.tgz", + "integrity": "sha512-OyXkWriNwb0lCF45eMmtjdOPEmfGKJxgGSnxpM7VxD0Vqr1qqtlcYyQG9wOHXNQrExvZv+uo922B2ZA4S77HsQ==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7071,9 +7071,9 @@ } }, "@types/babel__core": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.2.tgz", - "integrity": "sha512-pNpr1T1xLUc2l3xJKuPtsEky3ybxN3m4fJkknfIpTCTfIZCDW57oAg+EfCgIIp2rvCe0Wn++/FfodDS4YXxBwA==", + "version": "7.20.3", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.3.tgz", + "integrity": "sha512-54fjTSeSHwfan8AyHWrKbfBWiEUrNTZsUwPTDSNaaP1QDQIZbeNUg3a59E9D+375MzUw/x1vx2/0F5LBz+AeYA==", "dev": true, "requires": { "@babel/parser": "^7.20.7", @@ -7084,18 +7084,18 @@ } }, "@types/babel__generator": { - "version": "7.6.5", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.5.tgz", - "integrity": "sha512-h9yIuWbJKdOPLJTbmSpPzkF67e659PbQDba7ifWm5BJ8xTv+sDmS7rFmywkWOvXedGTivCdeGSIIX8WLcRTz8w==", + "version": "7.6.6", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.6.tgz", + "integrity": "sha512-66BXMKb/sUWbMdBNdMvajU7i/44RkrA3z/Yt1c7R5xejt8qh84iU54yUWCtm0QwGJlDcf/gg4zd/x4mpLAlb/w==", "dev": true, "requires": { "@babel/types": "^7.0.0" } }, "@types/babel__template": { - "version": "7.4.2", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.2.tgz", - "integrity": "sha512-/AVzPICMhMOMYoSx9MoKpGDKdBRsIXMNByh1PXSZoa+v6ZoLa8xxtsT/uLQ/NJm0XVAWl/BvId4MlDeXJaeIZQ==", + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.3.tgz", + "integrity": "sha512-ciwyCLeuRfxboZ4isgdNZi/tkt06m8Tw6uGbBSBgWrnnZGNXiEyM27xc/PjXGQLqlZ6ylbgHMnm7ccF9tCkOeQ==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -7103,51 +7103,51 @@ } }, "@types/babel__traverse": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.2.tgz", - "integrity": "sha512-ojlGK1Hsfce93J0+kn3H5R73elidKUaZonirN33GSmgTUMpzI/MIFfSpF3haANe3G1bEBS9/9/QEqwTzwqFsKw==", + "version": "7.20.3", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.3.tgz", + "integrity": "sha512-Lsh766rGEFbaxMIDH7Qa+Yha8cMVI3qAK6CHt3OR0YfxOIn5Z54iHiyDRycHrBqeIiqGa20Kpsv1cavfBKkRSw==", "dev": true, "requires": { "@babel/types": "^7.20.7" } }, "@types/graceful-fs": { - "version": "4.1.7", - "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.7.tgz", - "integrity": "sha512-MhzcwU8aUygZroVwL2jeYk6JisJrPl/oov/gsgGCue9mkgl9wjGbzReYQClxiUgFDnib9FuHqTndccKeZKxTRw==", + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.8.tgz", + "integrity": "sha512-NhRH7YzWq8WiNKVavKPBmtLYZHxNY19Hh+az28O/phfp68CF45pMFud+ZzJ8ewnxnC5smIdF3dqFeiSUQ5I+pw==", "dev": true, "requires": { "@types/node": "*" } }, "@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", + "integrity": "sha512-zONci81DZYCZjiLe0r6equvZut0b+dBRPBN5kBDjsONnutYNtJMoWQ9uR2RkL1gLG9NMTzvf+29e5RFfPbeKhQ==", "dev": true }, "@types/istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-gPQuzaPR5h/djlAv2apEG1HVOyj1IUs7GpfMZixU0/0KXT3pm64ylHuMUI1/Akh+sq/iikxg6Z2j+fcMDXaaTQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.2.tgz", + "integrity": "sha512-8toY6FgdltSdONav1XtUHl4LN1yTmLza+EuDazb/fEmRNCwjyqNVIQWs2IfC74IqjHkREs/nQ2FWq5kZU9IC0w==", "dev": true, "requires": { "@types/istanbul-lib-coverage": "*" } }, "@types/istanbul-reports": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.2.tgz", - "integrity": "sha512-kv43F9eb3Lhj+lr/Hn6OcLCs/sSM8bt+fIaP11rCYngfV6NVjzWXJ17owQtDQTL9tQ8WSLUrGsSJ6rJz0F1w1A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.3.tgz", + "integrity": "sha512-1nESsePMBlf0RPRffLZi5ujYh7IH1BWL4y9pr+Bn3cJBdxz+RTP8bUFljLz9HvzhhOSWKdyBZ4DIivdL6rvgZg==", "dev": true, "requires": { "@types/istanbul-lib-report": "*" } }, "@types/jest": { - "version": "29.5.5", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.5.tgz", - "integrity": "sha512-ebylz2hnsWR9mYvmBFbXJXr+33UPc4+ZdxyDXh5w0FlPBTfCVN3wPL+kuOiQt3xvrK419v7XWeAs+AeOksafXg==", + "version": "29.5.6", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.6.tgz", + "integrity": "sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==", "dev": true, "requires": { "expect": "^29.0.0", @@ -7160,12 +7160,9 @@ "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" }, "@types/node": { - "version": "20.8.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.6.tgz", - "integrity": "sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==", - "requires": { - "undici-types": "~5.25.1" - } + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" }, "@types/stack-utils": { "version": "2.0.1", @@ -7413,13 +7410,6 @@ "tiny-secp256k1": "^1.1.3", "typeforce": "^1.11.5", "wif": "^2.0.6" - }, - "dependencies": { - "@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" - } } }, "bip39": { @@ -7620,9 +7610,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001549", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz", - "integrity": "sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA==", + "version": "1.0.30001550", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001550.tgz", + "integrity": "sha512-p82WjBYIypO0ukTsd/FG3Xxs+4tFeaY9pfT4amQL8KWtYH7H9nYwReGAbMTJ0hsmRO8IfDtsS6p3ZWj8+1c2RQ==", "dev": true }, "chalk": { @@ -7895,9 +7885,9 @@ } }, "electron-to-chromium": { - "version": "1.4.554", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.554.tgz", - "integrity": "sha512-Q0umzPJjfBrrj8unkONTgbKQXzXRrH7sVV7D9ea2yBV3Oaogz991yhbpfvo2LMNkJItmruXTEzVpP9cp7vaIiQ==", + "version": "1.4.557", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.557.tgz", + "integrity": "sha512-6x0zsxyMXpnMJnHrondrD3SuAeKcwij9S+83j2qHAQPXbGTDDfgImzzwgGlzrIcXbHQ42tkG4qA6U860cImNhw==", "dev": true }, "elliptic": { @@ -9431,6 +9421,14 @@ "long": "^4.0.0" }, "dependencies": { + "@types/node": { + "version": "20.8.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", + "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", + "requires": { + "undici-types": "~5.25.1" + } + }, "long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", diff --git a/integration-tests/package.json b/integration-tests/package.json index fd9e2e0d..56ea3592 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^1.1.3", + "@terra-money/feather.js": "^1.2.1", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/helpers/const.ts b/integration-tests/src/helpers/const.ts index 2981dbc0..d9a13ba3 100644 --- a/integration-tests/src/helpers/const.ts +++ b/integration-tests/src/helpers/const.ts @@ -1,2 +1,4 @@ +export const SAFE_VOTING_PERIOD_TIME = 4100; export const SAFE_BLOCK_INCLUSION_TIME = 1100; export const blockInclusion = () => new Promise((resolve) => setTimeout(()=>resolve(SAFE_BLOCK_INCLUSION_TIME), SAFE_BLOCK_INCLUSION_TIME)); +export const votingPeriod = () => new Promise((resolve) => setTimeout(()=>resolve(SAFE_VOTING_PERIOD_TIME), SAFE_VOTING_PERIOD_TIME)); diff --git a/integration-tests/src/helpers/mnemonics.ts b/integration-tests/src/helpers/mnemonics.ts index 6c52c205..4a0de791 100644 --- a/integration-tests/src/helpers/mnemonics.ts +++ b/integration-tests/src/helpers/mnemonics.ts @@ -18,6 +18,9 @@ export function getMnemonics() { }) // Funded wallets available in both chains + let allianceMnemonic = new MnemonicKey({ + mnemonic: "broken title little open demand ladder mimic keen execute word couple door relief rule pulp demand believe cactus swing fluid tired what crop purse" + }) let pobMnemonic = new MnemonicKey({ mnemonic: "banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" }) @@ -34,9 +37,6 @@ export function getMnemonics() { mnemonic: "open attitude harsh casino rent attitude midnight debris describe spare cancel crisp olive ride elite gallery leaf buffalo sheriff filter rotate path begin soldier" }) // let mnemonic = new MnemonicKey({ - // mnemonic: "broken title little open demand ladder mimic keen execute word couple door relief rule pulp demand believe cactus swing fluid tired what crop purse" - // }) - // let mnemonic = new MnemonicKey({ // mnemonic: "unit question bulk desk slush answer share bird earth brave book wing special gorilla ozone release permit mercy luxury version advice impact unfair drama" // }) // let mnemonic = new MnemonicKey({ @@ -48,6 +48,7 @@ export function getMnemonics() { rly1, val2, rly2, + allianceMnemonic, feeshareMnemonic, pobMnemonic, pobMnemonic1, diff --git a/integration-tests/src/modules/alliance.test.ts b/integration-tests/src/modules/alliance.test.ts new file mode 100644 index 00000000..5e2441bf --- /dev/null +++ b/integration-tests/src/modules/alliance.test.ts @@ -0,0 +1,346 @@ +import { getMnemonics } from "../helpers/mnemonics"; +import { getLCDClient } from "../helpers/lcd.connection"; +import { Coin, MsgTransfer, MsgCreateAllianceProposal, MsgSubmitProposal, Coins, MsgVote, Fee, MsgAllianceDelegate, MsgClaimDelegationRewards, MsgAllianceUndelegate, MsgDeleteAllianceProposal } from "@terra-money/feather.js"; +import { blockInclusion, votingPeriod } from "../helpers/const"; +import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; +import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; + +describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/v0.3.x) ", () => { + // Prepare environment clients, accounts and wallets + const LCD = getLCDClient(); + const accounts = getMnemonics(); + const chain1Wallet = LCD.chain1.wallet(accounts.allianceMnemonic); + const val2Wallet = LCD.chain2.wallet(accounts.val2); + const val2WalletAddress = val2Wallet.key.accAddress("terra"); + const val2Address = val2Wallet.key.valAddress("terra"); + const allianceAccountAddress = accounts.allianceMnemonic.accAddress("terra"); + // This will be populated in the "Must create an alliance" + let ibcCoin = Coin.fromString("1uluna"); + + // Send uluna from chain-1 to chain-2 using + // the same wallet on both chains and start + // an Alliance creation process + beforeAll(async () => { + try { + let blockHeight = (await LCD.chain1.tendermint.blockInfo("test-1")).block.header.height; + let tx = await chain1Wallet.createAndSignTx({ + msgs: [new MsgTransfer( + "transfer", + "channel-0", + Coin.fromString("100000000uluna"), + allianceAccountAddress, + allianceAccountAddress, + new Height(2, parseInt(blockHeight) + 100), + undefined, + "" + )], + chainID: "test-1", + }); + + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult).toBeDefined(); + + // Check during 5 blocks for the receival + // of the IBC coin on chain-2 + for (let i = 0; i <= 5; i++) { + await blockInclusion(); + let _ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")); + if (_ibcCoin) { + expect(_ibcCoin.denom.startsWith("ibc/")).toBeTruthy(); + break; + } + } + } + catch (e) { + console.log(e) + expect(e).toBeUndefined(); + } + }); + + test('Must contain the expected module params', async () => { + try { + // Query Alliance module params + const moduleParams = await LCD.chain2.alliance.params("test-2"); + + // Validate that the params were set correctly on genesis + expect(moduleParams.params.take_rate_claim_interval) + .toBe("300s"); + expect(moduleParams.params.reward_delay_time) + .toBe("0s"); + } + catch (e) { + console.log(e) + expect(e).toBeUndefined(); + } + }); + + test('Must create an alliance', async () => { + // Query the IBC coin and check if there is any + // which menas that the IBC transfer was successful + for (let i = 0; i <= 5; i++) { + await blockInclusion(); + let _ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")); + if (_ibcCoin) { + ibcCoin = _ibcCoin; + break; + } + } + expect(ibcCoin.denom.startsWith("ibc/")).toBeTruthy(); + + try { + // Create an alliance proposal sign and submit on chain-2 + let tx = await val2Wallet.createAndSignTx({ + msgs: [new MsgSubmitProposal( + new MsgCreateAllianceProposal( + "title", + "description", + ibcCoin.denom, + "100000000000000000", + "0", + "1000000000000000000", + undefined, + { + "min": "100000000000000000", + "max": "100000000000000000" + } + ), + Coins.fromString("1000000000uluna"), + val2WalletAddress, + )], + chainID: "test-2", + }); + let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await blockInclusion(); + + // Check that the proposal was created successfully + let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any; + expect(txResult.code).toBe(0); + + // Get the proposal id and validate exists + let proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); + expect(proposalId) + + // Vote for the proposal + tx = await val2Wallet.createAndSignTx({ + msgs: [new MsgVote( + proposalId, + val2WalletAddress, + VoteOption.VOTE_OPTION_YES + )], + fee: new Fee(100_000, "0uluna"), + chainID: "test-2", + }); + result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await votingPeriod(); + txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") + expect(txResult.code).toBe(0); + } + catch (e: any) { + expect(e.response.data.message).toContain("alliance asset already exists"); + } + + // Query the alliance and check if it exists + const res = await LCD.chain2.alliance.alliance("test-2", ibcCoin.denom); + expect(res).toBeDefined(); + expect(res.alliance.denom).toBe(ibcCoin.denom); + expect(res.alliance.reward_weight).toBe("0.100000000000000000"); + expect(res.alliance.take_rate).toBe("0.000000000000000000"); + expect(res.alliance.reward_weight_range?.min).toBe("0.100000000000000000") + expect(res.alliance.reward_weight_range?.max).toBe("0.100000000000000000") + expect(res.alliance.is_initialized).toBeTruthy(); + }); + + describe("After Alliance has been created", () => { + test('Must delegate to the alliance', async () => { + const allianceWallet2 = LCD.chain2.wallet(accounts.allianceMnemonic); + let ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")) as Coin; + let tx = await allianceWallet2.createAndSignTx({ + msgs: [ + new MsgAllianceDelegate( + allianceAccountAddress, + val2Address, + new Coin(ibcCoin.denom, 1000), + ) + ], + chainID: "test-2", + }); + let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await blockInclusion(); + + // Check that the proposal was created successfully + let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any; + expect(txResult.code).toBe(0); + + // Validate the delegation event + let delegationEvents = txResult.logs[0].eventsByType["alliance.alliance.DelegateAllianceEvent"]; + expect(delegationEvents.allianceSender) + .toStrictEqual([`"${allianceAccountAddress}"`]) + expect(delegationEvents.coin) + .toStrictEqual([`{\"denom\":\"${ibcCoin.denom}\",\"amount\":\"1000\"}`]) + expect(delegationEvents.newShares) + .toStrictEqual([`"1000.000000000000000000"`]) + expect(delegationEvents.validator) + .toStrictEqual([`"${val2Address}"`]) + }); + + test('Must query one alliance validators', async () => { + const res = await LCD.chain2.alliance.alliancesByValidator(val2Address); + expect(res) + .toStrictEqual({ + "validator_addr": val2Address, + "total_delegation_shares": [{ + "denom": ibcCoin.denom, + "amount": "1000.000000000000000000" + }], + "validator_shares": [{ + "denom": ibcCoin.denom, + "amount": "1000.000000000000000000" + }], + "total_staked": [{ + "denom": ibcCoin.denom, + "amount": "1000.000000000000000000" + }] + }) + }); + + test('Must query all alliance validators', async () => { + const res = await LCD.chain2.alliance.alliancesByValidators("test-2"); + expect(res) + .toStrictEqual({ + "validators": [{ + "validator_addr": val2Address, + "total_delegation_shares": [{ + "denom": ibcCoin.denom, + "amount": "1000.000000000000000000" + }], + "validator_shares": [{ + "denom": ibcCoin.denom, + "amount": "1000.000000000000000000" + }], + "total_staked": [{ + "denom": ibcCoin.denom, + "amount": "1000.000000000000000000" + }] + }], + "pagination": { + "next_key": null, + "total": "1" + } + }) + }); + + describe("After delegation", () => { + test("Must claim rewards from the alliance", async () => { + const allianceWallet2 = LCD.chain2.wallet(accounts.allianceMnemonic); + let ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")) as Coin; + let tx = await allianceWallet2.createAndSignTx({ + msgs: [ + new MsgClaimDelegationRewards( + allianceAccountAddress, + val2Address, + ibcCoin.denom, + ), + ], + fee: new Fee(300_000, "0uluna"), + chainID: "test-2", + }); + let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await blockInclusion(); + + // Check that the proposal was created successfully + let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any; + expect(txResult.code).toBe(0); + + // Validate the delegation event + let claimRewardsEvent = txResult.logs[0].eventsByType["alliance.alliance.ClaimAllianceRewardsEvent"]; + expect(claimRewardsEvent.allianceSender) + .toStrictEqual([`"${allianceAccountAddress}"`]) + expect(claimRewardsEvent.validator) + .toStrictEqual([`"${val2Address}"`]) + }) + + test("Must undelegate from the alliance", async () => { + await blockInclusion(); + const allianceWallet2 = LCD.chain2.wallet(accounts.allianceMnemonic); + let ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")) as Coin; + let tx = await allianceWallet2.createAndSignTx({ + msgs: [ + new MsgAllianceUndelegate( + allianceAccountAddress, + val2Address, + new Coin(ibcCoin.denom, 1000), + ), + ], + fee: new Fee(300_000, "0uluna"), + chainID: "test-2", + }); + let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await blockInclusion(); + + // Check that the proposal was created successfully + let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any; + expect(txResult.code).toBe(0); + + // Validate the delegation event + let undelegateEvent = txResult.logs[0].eventsByType["alliance.alliance.UndelegateAllianceEvent"]; + expect(undelegateEvent.allianceSender) + .toStrictEqual([`"${allianceAccountAddress}"`]) + expect(undelegateEvent.coin) + .toStrictEqual([`{\"denom\":\"${ibcCoin.denom}\",\"amount\":\"1000\"}`]) + expect(undelegateEvent.validator) + .toStrictEqual([`"${val2Address}"`]) + }) + }) + }) + + describe("After interacting with the Alliance", () => { + test('Must removed the alliance using gov', async () => { + let ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")) as Coin; + + // Create a delete alliance proposal sign and submit on chain-2 + let tx = await val2Wallet.createAndSignTx({ + msgs: [new MsgSubmitProposal( + new MsgDeleteAllianceProposal( + "title", + "description", + ibcCoin.denom, + ), + Coins.fromString("1000000000uluna"), + val2WalletAddress, + )], + chainID: "test-2", + }); + let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await blockInclusion(); + + // Check that the proposal was created successfully + let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any; + expect(txResult.code).toBe(0); + + // Get the proposal id and validate exists + let proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); + expect(proposalId) + + // Vote for the proposal + tx = await val2Wallet.createAndSignTx({ + msgs: [new MsgVote( + proposalId, + val2WalletAddress, + VoteOption.VOTE_OPTION_YES + )], + fee: new Fee(100_000, "0uluna"), + chainID: "test-2", + }); + result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await votingPeriod(); + txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") + expect(txResult.code).toBe(0); + + // Query the alliance and check if it exists + const res = await LCD.chain2.alliance.alliances("test-2"); + expect(res.alliances.length).toBe(0); + }); + }) +}); \ No newline at end of file diff --git a/scripts/tests/alliance/delegate.sh b/scripts/tests/alliance/delegate.sh deleted file mode 100755 index 751157b9..00000000 --- a/scripts/tests/alliance/delegate.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash - -echo "" -echo "#################################################" -echo "# Alliance: bridge funds and create an alliance #" -echo "#################################################" -echo "" - -BINARY=terrad -CHAIN_DIR=$(pwd)/data - -AMOUNT_TO_DELEGATE=10000000000 -ULUNA_DENOM=uluna -VAL_WALLET_1=$($BINARY keys show val1 -a --keyring-backend test --home $CHAIN_DIR/test-1) -VAL_WALLET_2=$($BINARY keys show val2 -a --keyring-backend test --home $CHAIN_DIR/test-2) - -echo "Sending tokens from validator wallet on test-1 to validator wallet on test-2" -IBC_TRANSFER=$($BINARY tx ibc-transfer transfer transfer channel-0 $VAL_WALLET_2 $AMOUNT_TO_DELEGATE$ULUNA_DENOM --chain-id test-1 --from $VAL_WALLET_1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 --keyring-backend test -y -o json | jq -r '.raw_log' ) - -if [[ "$IBC_TRANSFER" == "failed to execute message"* ]]; then - echo "Error: IBC transfer failed, with error: $IBC_TRANSFER" - exit 1 -fi - -ACCOUNT_BALANCE="" -IBC_DENOM="" -while [ "$ACCOUNT_BALANCE" == "" ]; do - IBC_DENOM=$($BINARY q bank balances $VAL_WALLET_2 --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.balances[0].denom') - if [ "$IBC_DENOM" != "$ULUNA_DENOM" ]; then - ACCOUNT_BALANCE=$($BINARY q bank balances $VAL_WALLET_2 --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.balances[0].amount') - fi - sleep 2 -done - -GOV_ADDRESS=$($BINARY query auth module-account gov --output json | jq .account.base_account.address -r) -echo '{ - "messages": [ - { - "@type": "/alliance.alliance.MsgCreateAlliance", - "authority" : "'"$GOV_ADDRESS"'", - "denom": "'"$IBC_DENOM"'", - "reward_weight": "0.3", - "take_rate": "0.01", - "reward_change_rate": "0.01", - "reward_change_interval": "10s", - "reward_weight_range": { - "min":"0.0001", - "max":"0.3" - } - } - ], - "metadata": "", - "deposit": "550000000'$ULUNA_DENOM'", - "title": "Create an Alliance!", - "summary": "Source Code Version https://github.com/terra-money/core" -}' > $CHAIN_DIR/create-alliance.json - -echo "Creating an alliance with the denom $IBC_DENOM" -PROPOSAL_HEIGHT=$($BINARY tx gov submit-proposal $CHAIN_DIR/create-alliance.json --from=$VAL_WALLET_2 --home $CHAIN_DIR/test-2 --node tcp://localhost:26657 -o json --keyring-backend test --gas 1000000 -y | jq -r '.height') -sleep 3 -PROPOSAL_ID=$($BINARY query gov proposals --home $CHAIN_DIR/test-2 --count-total --node tcp://localhost:26657 -o json --output json --chain-id=test-2 | jq .proposals[-1].id -r) -VOTE_RES=$($BINARY tx gov vote $PROPOSAL_ID yes --from=$VAL_WALLET_2 --home $CHAIN_DIR/test-2 --keyring-backend=test --gas 1000000 --chain-id=test-2 --node tcp://localhost:26657 -o json -y) - -ALLIANCE="null" -while [ "$ALLIANCE" == "null" ]; do - echo "Waiting for alliance with denom $IBC_DENOM to be created" - ALLIANCE=$($BINARY q alliance alliances --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.alliances[0]') - sleep 2 -done - -echo "Delegating $AMOUNT_TO_DELEGATE to the alliance $IBC_DENOM" -VAL_ADDR=$($BINARY query staking validators --output json | jq .validators[0].operator_address --raw-output) -DELEGATE_RES=$($BINARY tx alliance delegate $VAL_ADDR $AMOUNT_TO_DELEGATE$IBC_DENOM --from=node0 --from=$VAL_WALLET_2 --home $CHAIN_DIR/test-2 --keyring-backend=test --gas 1000000 --chain-id=test-2 -o json -y) -sleep 3 -DELEGATIONS=$($BINARY query alliance delegation $VAL_WALLET_2 $VAL_ADDR $IBC_DENOM --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.delegation.balance.amount') -if [[ "$DELEGATIONS" == "0" ]]; then - echo "Error: Alliance delegations expected to be greater than 0" - exit 1 -fi - -echo "Query bank balance after alliance creation" -TOTAL_SUPPLY_BEFORE_ALLIANCE=$($BINARY query bank total --denom $ULUNA_DENOM --height $PROPOSAL_HEIGHT -o json | jq -r '.amount') -TOTAL_SUPPLY_AFTER_ALLIANCE=$($BINARY query bank total --denom $ULUNA_DENOM -o json | jq -r '.amount') -TOTAL_SUPPLY_INCREMENT=$(($TOTAL_SUPPLY_BEFORE_ALLIANCE - $TOTAL_SUPPLY_AFTER_ALLIANCE)) - - -if [ "$TOTAL_SUPPLY_INCREMENT" -gt 100000 ] && [ "$TOTAL_SUPPLY_INCREMENT" -lt 1000000 ]; then - echo "Error: Something went wrong, total supply of $ULUNA_DENOM has increased out of range 100_000 between 1_000_000. current value $TOTAL_SUPPLY_INCREMENT" - exit 1 -fi - -echo "" -echo "#########################################################" -echo "# Success: Alliance bridge funds and create an alliance #" -echo "#########################################################" -echo "" \ No newline at end of file diff --git a/scripts/tests/init-test-framework.sh b/scripts/tests/init-test-framework.sh index 6de74541..4a5578f6 100755 --- a/scripts/tests/init-test-framework.sh +++ b/scripts/tests/init-test-framework.sh @@ -152,8 +152,8 @@ sed -i -e 's#"tcp://localhost:1317"#"tcp://localhost:'"$RESTPORT_2"'"#g' $CHAIN_ sed -i -e 's#":8080"#":'"$ROSETTA_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/app.toml echo "Chaning genesis.json..." -sed -i -e 's/"voting_period": "172800s"/"voting_period": "10s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json -sed -i -e 's/"voting_period": "172800s"/"voting_period": "10s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json +sed -i -e 's/"voting_period": "172800s"/"voting_period": "4s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json +sed -i -e 's/"voting_period": "172800s"/"voting_period": "4s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json sed -i -e 's/"reward_delay_time": "604800s"/"reward_delay_time": "0s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json sed -i -e 's/"reward_delay_time": "604800s"/"reward_delay_time": "0s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json From 977cdeb8893675eb8699c78080d9417cdca9a5cc Mon Sep 17 00:00:00 2001 From: emidev98 Date: Thu, 19 Oct 2023 17:38:11 +0200 Subject: [PATCH 2/3] feat: gov v1 and legacy tests --- .../src/modules/alliance.test.ts | 59 ++++++------ integration-tests/src/modules/gov.test.ts | 96 +++++++++++++++++++ 2 files changed, 128 insertions(+), 27 deletions(-) create mode 100644 integration-tests/src/modules/gov.test.ts diff --git a/integration-tests/src/modules/alliance.test.ts b/integration-tests/src/modules/alliance.test.ts index 5e2441bf..a970f1b9 100644 --- a/integration-tests/src/modules/alliance.test.ts +++ b/integration-tests/src/modules/alliance.test.ts @@ -1,6 +1,6 @@ import { getMnemonics } from "../helpers/mnemonics"; import { getLCDClient } from "../helpers/lcd.connection"; -import { Coin, MsgTransfer, MsgCreateAllianceProposal, MsgSubmitProposal, Coins, MsgVote, Fee, MsgAllianceDelegate, MsgClaimDelegationRewards, MsgAllianceUndelegate, MsgDeleteAllianceProposal } from "@terra-money/feather.js"; +import { Coin, MsgTransfer, MsgCreateAlliance, Coins, MsgVote, Fee, MsgAllianceDelegate, MsgClaimDelegationRewards, MsgAllianceUndelegate, MsgDeleteAlliance, MsgSubmitProposal } from "@terra-money/feather.js"; import { blockInclusion, votingPeriod } from "../helpers/const"; import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; @@ -90,25 +90,27 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ expect(ibcCoin.denom.startsWith("ibc/")).toBeTruthy(); try { + const msgProposal = new MsgSubmitProposal( + [new MsgCreateAlliance( + "terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n", + ibcCoin.denom, + "100000000000000000", + "0", + "1000000000000000000", + undefined, + { + "min": "100000000000000000", + "max": "100000000000000000" + })], + Coins.fromString("1000000000uluna"), + val2WalletAddress, + "metadata", + "title", + "summary" + ); // Create an alliance proposal sign and submit on chain-2 let tx = await val2Wallet.createAndSignTx({ - msgs: [new MsgSubmitProposal( - new MsgCreateAllianceProposal( - "title", - "description", - ibcCoin.denom, - "100000000000000000", - "0", - "1000000000000000000", - undefined, - { - "min": "100000000000000000", - "max": "100000000000000000" - } - ), - Coins.fromString("1000000000uluna"), - val2WalletAddress, - )], + msgs: [msgProposal], chainID: "test-2", }); let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); @@ -299,17 +301,20 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ test('Must removed the alliance using gov', async () => { let ibcCoin = (await LCD.chain2.bank.balance(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/")) as Coin; + const msgProposal = new MsgSubmitProposal( + [new MsgDeleteAlliance( + "terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n", + ibcCoin.denom, + )], + Coins.fromString("1000000000uluna"), + val2WalletAddress, + "metadata", + "title", + "summary" + ); // Create a delete alliance proposal sign and submit on chain-2 let tx = await val2Wallet.createAndSignTx({ - msgs: [new MsgSubmitProposal( - new MsgDeleteAllianceProposal( - "title", - "description", - ibcCoin.denom, - ), - Coins.fromString("1000000000uluna"), - val2WalletAddress, - )], + msgs: [msgProposal], chainID: "test-2", }); let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); diff --git a/integration-tests/src/modules/gov.test.ts b/integration-tests/src/modules/gov.test.ts new file mode 100644 index 00000000..68a2f6b9 --- /dev/null +++ b/integration-tests/src/modules/gov.test.ts @@ -0,0 +1,96 @@ +import { getMnemonics } from "../helpers/mnemonics"; +import { getLCDClient } from "../helpers/lcd.connection"; +import { Coins, MsgVote, Fee, MsgSubmitProposal } from "@terra-money/feather.js"; +import { blockInclusion, votingPeriod } from "../helpers/const"; +import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; + +describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/v0.3.x) ", () => { + // Prepare environment clients, accounts and wallets + const LCD = getLCDClient(); + const accounts = getMnemonics(); + const val2Wallet = LCD.chain2.wallet(accounts.val2); + const val2WalletAddress = val2Wallet.key.accAddress("terra"); + + test('Must contain the expected module params', async () => { + try { + // Query Alliance module params + const moduleParams = await LCD.chain2.gov.params("test-2"); + + // Validate that the params were set correctly on genesis + expect(moduleParams) + .toStrictEqual({ + "deposit_params": { + "max_deposit_period": "172800s", + "min_deposit": [ + { + "amount": "10000000", + "denom": "uluna", + }, + ], + }, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + }, + "voting_params": { + "voting_period": "4s", + }, + }); + } + catch (e) { + console.log(e) + expect(e).toBeUndefined(); + } + }); + + test('Must submit a proposal on chain', async () => { + try { + const msgProposal = new MsgSubmitProposal( + [], + Coins.fromString("1000000000uluna"), + val2WalletAddress, + "metadata", + "title", + "summary" + ); + // Create an alliance proposal sign and submit on chain-2 + let tx = await val2Wallet.createAndSignTx({ + msgs: [msgProposal], + chainID: "test-2", + }); + let result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await blockInclusion(); + + // Check that the proposal was created successfully + let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any; + expect(txResult.code).toBe(0); + + // Get the proposal id and validate exists + let proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); + expect(proposalId) + + // Vote for the proposal + tx = await val2Wallet.createAndSignTx({ + msgs: [new MsgVote( + proposalId, + val2WalletAddress, + VoteOption.VOTE_OPTION_YES + )], + fee: new Fee(100_000, "0uluna"), + chainID: "test-2", + }); + result = await LCD.chain2.tx.broadcastSync(tx, "test-2"); + await votingPeriod(); + txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") + expect(txResult.code).toBe(0); + } + catch (e: any) { + expect(e.response.data.message).toContain("alliance asset already exists"); + } + + // Query the alliance and check if it exists + const res = await LCD.chain2.gov.proposals("test-2"); + expect(res).toBeDefined(); + }) +}); \ No newline at end of file From f7406ce003c399e952a05b64836b35acf80b094c Mon Sep 17 00:00:00 2001 From: emidev98 Date: Fri, 20 Oct 2023 12:36:54 +0200 Subject: [PATCH 3/3] test: gov module increase coverage --- integration-tests/package-lock.json | 14 +- integration-tests/package.json | 2 +- integration-tests/src/modules/gov.test.ts | 156 +++++++++++++++++++++- 3 files changed, 157 insertions(+), 15 deletions(-) diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 6d7427ed..ccaf43cc 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.6.2", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^1.2.1", + "@terra-money/feather.js": "^2.0.0-beta.1", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.2.1.tgz", - "integrity": "sha512-OyXkWriNwb0lCF45eMmtjdOPEmfGKJxgGSnxpM7VxD0Vqr1qqtlcYyQG9wOHXNQrExvZv+uo922B2ZA4S77HsQ==", + "version": "2.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.1.tgz", + "integrity": "sha512-cT8pNNvVEql9vni5SVk4d3+FBqVD9/D+A+qOhXJAvOs0cOG6NFEKmpBbhJlGegqlnr+Gksxp5bJ0YO2XYac2Vw==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.2.1.tgz", - "integrity": "sha512-OyXkWriNwb0lCF45eMmtjdOPEmfGKJxgGSnxpM7VxD0Vqr1qqtlcYyQG9wOHXNQrExvZv+uo922B2ZA4S77HsQ==", + "version": "2.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.1.tgz", + "integrity": "sha512-cT8pNNvVEql9vni5SVk4d3+FBqVD9/D+A+qOhXJAvOs0cOG6NFEKmpBbhJlGegqlnr+Gksxp5bJ0YO2XYac2Vw==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index 56ea3592..381ed2a0 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^1.2.1", + "@terra-money/feather.js": "^2.0.0-beta.1", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/modules/gov.test.ts b/integration-tests/src/modules/gov.test.ts index 68a2f6b9..a7cab5ce 100644 --- a/integration-tests/src/modules/gov.test.ts +++ b/integration-tests/src/modules/gov.test.ts @@ -1,21 +1,21 @@ import { getMnemonics } from "../helpers/mnemonics"; import { getLCDClient } from "../helpers/lcd.connection"; -import { Coins, MsgVote, Fee, MsgSubmitProposal } from "@terra-money/feather.js"; +import { Coins, MsgVote, Fee, MsgSubmitProposal, Proposal, Int } from "@terra-money/feather.js"; import { blockInclusion, votingPeriod } from "../helpers/const"; -import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; +import { ProposalStatus, VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; -describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/v0.3.x) ", () => { +describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0.47.x/x/gov) ", () => { // Prepare environment clients, accounts and wallets const LCD = getLCDClient(); const accounts = getMnemonics(); const val2Wallet = LCD.chain2.wallet(accounts.val2); const val2WalletAddress = val2Wallet.key.accAddress("terra"); + let proposalId = 0; // Will be populated on "Must submit a proposal on chain" test('Must contain the expected module params', async () => { try { - // Query Alliance module params + // Query All gov module params const moduleParams = await LCD.chain2.gov.params("test-2"); - // Validate that the params were set correctly on genesis expect(moduleParams) .toStrictEqual({ @@ -36,6 +36,111 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ "voting_params": { "voting_period": "4s", }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); + + // Query tally module params + const tallyParams = await LCD.chain2.gov.tallyParams("test-2"); + // Validate that the params were set correctly on genesis + expect(tallyParams) + .toStrictEqual({ + "deposit_params": null, + "voting_params": null, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); + + // Query voting gov module params + const votingParams = await LCD.chain2.gov.votingParams("test-2"); + // Validate that the params were set correctly on genesis + expect(votingParams) + .toStrictEqual({ + "deposit_params": null, + "tally_params": null, + "voting_params": { + "voting_period": "4s", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); + + + // Query deposit gov module params + const depositParams = await LCD.chain2.gov.depositParams("test-2"); + // Validate that the params were set correctly on genesis + expect(depositParams) + .toStrictEqual({ + "voting_params": null, + "tally_params": null, + "deposit_params": { + "max_deposit_period": "172800s", + "min_deposit": [ + { + "amount": "10000000", + "denom": "uluna", + }, + ], + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, }); } catch (e) { @@ -44,7 +149,7 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ } }); - test('Must submit a proposal on chain', async () => { + test('Must submit an empty proposal on chain', async () => { try { const msgProposal = new MsgSubmitProposal( [], @@ -67,7 +172,7 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ expect(txResult.code).toBe(0); // Get the proposal id and validate exists - let proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); + proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); expect(proposalId) // Vote for the proposal @@ -92,5 +197,42 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ // Query the alliance and check if it exists const res = await LCD.chain2.gov.proposals("test-2"); expect(res).toBeDefined(); + }); + + describe("After submitting the proposal on chain", () => { + test('Must query the proposals', async () => { + // Query the alliance and check if it exists + const res = await LCD.chain2.gov.proposals("test-2"); + let proposal; + for (const prop of res.proposals) { + if (prop.id === proposalId){ + proposal = prop; + } + } + expect(proposal).toBeDefined(); + proposal = proposal as Proposal; + expect(proposal.id).toBe(proposalId); + expect(proposal.proposer).toBe(val2WalletAddress); + expect(proposal.metadata).toBe("metadata"); + expect(proposal.title).toBe("title"); + expect(proposal.summary).toBe("summary"); + expect(proposal.messages.length).toBe(0); + expect(proposal.total_deposit).toStrictEqual(Coins.fromString("1000000000uluna")); + expect(proposal.submit_time.getTime()).toBeLessThan(Date.now()); + expect(proposal.voting_start_time?.getTime()).toBeLessThan(Date.now()); + expect(proposal.deposit_end_time?.getTime()).toBeGreaterThan(Date.now()); + expect(proposal.voting_end_time?.getTime()).toBeLessThan(Date.now()); + expect(proposal.status).toBe(ProposalStatus.PROPOSAL_STATUS_PASSED) + }); + + test('Must query the tally', async () => { + // Query the alliance and check if it exists + const res = await LCD.chain2.gov.tally("test-2", proposalId); + expect(res).toBeDefined(); + expect(res.yes_count).toStrictEqual(new Int(27000000000)); + expect(res.abstain_count).toStrictEqual(new Int(0)); + expect(res.no_count).toStrictEqual(new Int(0)); + expect(res.no_with_veto_count).toStrictEqual(new Int(0)); + }); }) }); \ No newline at end of file