├── .gitignore ├── .markdownlint.json ├── CONTRIBUTING ├── LICENSE ├── Oasis ├── intro-to-oasis │ ├── assets │ │ ├── cherry-order.png │ │ ├── cherry-transaction.png │ │ ├── order-book-1.png │ │ ├── order.png │ │ ├── sell-order.png │ │ └── transaction.png │ └── intro-to-oasis.md ├── oasis-direct-proxy │ └── oasis-direct-proxy.md ├── oasisdex-market-maker-guide │ └── oasisdex-market-maker-guide.md ├── oasisdex-market-taker-guide │ └── oasisdex-market-taker-guide.md └── oasisdex-ui-guide │ └── oasisdex-ui-guide.md ├── README.md ├── dai ├── README.md ├── dai-in-smart-contracts │ ├── dai-in-smart-contracts.md │ └── images │ │ ├── CompileVersion.png │ │ ├── DaiFaucet.png │ │ ├── Deploy.png │ │ ├── FullContract.png │ │ ├── Interact.png │ │ ├── Successfull.png │ │ ├── compiled.png │ │ ├── pasteCode.png │ │ ├── verify.png │ │ └── verifyAndPublish.png ├── dai-supply │ ├── dai-supply.md │ └── images │ │ └── dai_venn.png ├── dai-token │ └── dai-token.md ├── dsr-integration-guide │ ├── dsr-integration-guide.md │ ├── dsr.sol │ └── dsrManagerExample.sol ├── dsr-manager-docs │ └── dsr-manager-docs.md └── how-to-use-permit-function │ └── how-to-use-permit-function.md ├── devtools ├── Dai.js │ └── How-to-build-dai-js-wallet-plugin.md ├── README.md ├── seth │ └── seth-guide │ │ └── seth-guide.md ├── test-chain-guide │ └── test-chain-guide.md └── working-with-dsproxy │ └── working-with-dsproxy.md ├── exchanges ├── README.md └── exchanges-guide │ └── exchanges-guide.md ├── gnosis-multisig ├── dsr-gnosis-multisig-guide │ ├── dsr-gnosis-multisig-guide.md │ └── dsr-manager-gnosis-multisig-guide.md ├── migrating-gnosis-multisig-guide │ └── migrating-gnosis-multisig-guide.md ├── nested-multisig-gnosis-safe-wallet-setup-walkthrough │ ├── nested-multisig-gnosis-safe-wallet-setup-walkthrough.md │ └── pictures │ │ ├── NestedMultiSig.jpg │ │ ├── Untitled 1.png │ │ ├── Untitled 2.png │ │ ├── Untitled 3.png │ │ ├── Untitled 4.png │ │ ├── Untitled 5.png │ │ ├── Untitled 6.png │ │ ├── Untitled 7.png │ │ ├── Untitled 8.png │ │ ├── Untitled 9.png │ │ └── Untitled.png └── vote-proxy-setup-gnosis-multisig │ ├── pictures │ ├── proxyFactory.png │ ├── proxycontract.png │ └── voteFront.png │ └── vote-proxy-setup-gnosis-multisig.md ├── governance ├── README.md ├── collateral-redemption-during-emergency-shutdown │ └── Collateral Redemption during Emergency Shutdown.md ├── emergency-shutdown-cli-documentation │ └── Emergency-Shutdown-CLI-Documentation.md └── vote-proxy-setup-airgapped-machine │ ├── pictures │ ├── lock.png │ ├── lockmkr.png │ ├── proxycontract.png │ ├── voteFront.png │ └── voteproxyfactory.png │ └── vote-proxy-setup-airgapped-machine.md ├── keepers ├── README.md ├── auction-keeper ├── auction-keeper-bot-setup-guide │ └── auction-keeper-bot-setup-guide.md ├── market-maker-keeper-bot-setup-guide │ └── market-maker-keeper-bot-setup-guide.md └── simple-arbitrage-keeper │ ├── pictures │ └── lifecycle.jpeg │ └── simple-arbitrage-keeper.md ├── market-makers └── market-makers.md ├── mcd ├── README.md ├── add-collateral-type-testnet │ └── add-collateral-type-testnet.md ├── collateral-auction-integration-guide │ └── collateral-auction-integration-guide.md ├── emergency-shutdown-design-patterns │ └── emergency-shutdown-design-patterns.md ├── emergency-shutdown │ └── emergency-shutdown.md ├── intro-rate-mechanism │ └── intro-rate-mechanism.md ├── mcd-101 │ ├── mcd-101.md │ └── pictures │ │ ├── 50_1.png │ │ ├── 50_2.png │ │ ├── 51_1.png │ │ ├── 51_2.png │ │ ├── 51_3.png │ │ ├── CDP.png │ │ ├── Proxy.png │ │ ├── SRupdated.png │ │ ├── assetStates.png │ │ ├── auction.png │ │ ├── bitcoinChart.png │ │ ├── cdps.png │ │ ├── cdpstates.png │ │ ├── daiDrawn.png │ │ ├── daipeg.png │ │ ├── governance.png │ │ ├── house.png │ │ ├── idealactrate.png │ │ ├── interactionD.png │ │ ├── oracle.png │ │ ├── smartContracts.png │ │ └── supplyDemand.png ├── mcd-cli │ └── mcd-cli-guide │ │ └── mcd-cli-guide.md ├── mcd-deplyoment │ └── mcd-deployment.md ├── mcd-seth │ └── mcd-seth.md └── upgrading-to-multi-collateral-dai │ ├── cli-mcd-migration.md │ ├── figures │ ├── cdpmigration.png │ ├── exchangedaimigration.png │ ├── migrating10sai.png │ ├── saimigration.png │ ├── saimigrationfunctions.png │ └── userflowexchange.png │ └── upgrading-to-multi-collateral-dai.md ├── mkr └── mkr-token │ └── mkr-token.md ├── oracles └── oracle-integration-guide.md ├── sample └── sample-guide │ └── sample-guide.md ├── tests ├── README.MD ├── devtools │ ├── mcd-cli │ │ ├── mcd-cli.MD │ │ └── test │ │ │ ├── account │ │ │ ├── mcd-cli-test-keystore │ │ │ └── pass │ │ │ ├── libs │ │ │ ├── bats-assert │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── load.bash │ │ │ │ ├── package.json │ │ │ │ ├── script │ │ │ │ │ └── install-bats.sh │ │ │ │ ├── src │ │ │ │ │ └── assert.bash │ │ │ │ └── test │ │ │ │ │ ├── 50-assert-11-assert.bats │ │ │ │ │ ├── 50-assert-12-assert_equal.bats │ │ │ │ │ ├── 50-assert-13-assert_success.bats │ │ │ │ │ ├── 50-assert-14-assert_failure.bats │ │ │ │ │ ├── 50-assert-15-assert_output.bats │ │ │ │ │ ├── 50-assert-16-refute_output.bats │ │ │ │ │ ├── 50-assert-17-assert_line.bats │ │ │ │ │ ├── 50-assert-18-refute_line.bats │ │ │ │ │ ├── 50-assert-19-refute.bats │ │ │ │ │ └── test_helper.bash │ │ │ ├── bats-support │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── load.bash │ │ │ │ ├── package.json │ │ │ │ ├── script │ │ │ │ │ └── install-bats.sh │ │ │ │ ├── src │ │ │ │ │ ├── error.bash │ │ │ │ │ ├── lang.bash │ │ │ │ │ └── output.bash │ │ │ │ └── test │ │ │ │ │ ├── 50-output-10-batslib_err.bats │ │ │ │ │ ├── 50-output-11-batslib_count_lines.bats │ │ │ │ │ ├── 50-output-12-batslib_is_single_line.bats │ │ │ │ │ ├── 50-output-13-batslib_get_max_single_line_key_width.bats │ │ │ │ │ ├── 50-output-14-batslib_print_kv_single.bats │ │ │ │ │ ├── 50-output-15-batslib_print_kv_multi.bats │ │ │ │ │ ├── 50-output-16-batslib_print_kv_single_or_multi.bats │ │ │ │ │ ├── 50-output-17-batslib_prefix.bats │ │ │ │ │ ├── 50-output-18-batslib_mark.bats │ │ │ │ │ ├── 50-output-19-batslib_decorate.bats │ │ │ │ │ ├── 51-error-10-fail.bats │ │ │ │ │ ├── 52-lang-10-batslib_is_caller.bats │ │ │ │ │ └── test_helper.bash │ │ │ └── bats │ │ │ │ ├── .gitattributes │ │ │ │ ├── .travis.yml │ │ │ │ ├── CONDUCT.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── bin │ │ │ │ └── bats │ │ │ │ ├── install.sh │ │ │ │ ├── libexec │ │ │ │ ├── bats │ │ │ │ ├── bats-exec-suite │ │ │ │ ├── bats-exec-test │ │ │ │ ├── bats-format-tap-stream │ │ │ │ └── bats-preprocess │ │ │ │ ├── man │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── bats.1 │ │ │ │ ├── bats.1.ronn │ │ │ │ ├── bats.7 │ │ │ │ └── bats.7.ronn │ │ │ │ ├── package.json │ │ │ │ └── test │ │ │ │ ├── bats.bats │ │ │ │ ├── fixtures │ │ │ │ ├── bats │ │ │ │ │ ├── dos_line.bats │ │ │ │ │ ├── empty.bats │ │ │ │ │ ├── environment.bats │ │ │ │ │ ├── failing.bats │ │ │ │ │ ├── failing_and_passing.bats │ │ │ │ │ ├── failing_helper.bats │ │ │ │ │ ├── failing_setup.bats │ │ │ │ │ ├── failing_teardown.bats │ │ │ │ │ ├── intact.bats │ │ │ │ │ ├── invalid_tap.bats │ │ │ │ │ ├── load.bats │ │ │ │ │ ├── loop_keep_IFS.bats │ │ │ │ │ ├── output.bats │ │ │ │ │ ├── passing.bats │ │ │ │ │ ├── passing_and_failing.bats │ │ │ │ │ ├── passing_and_skipping.bats │ │ │ │ │ ├── passing_failing_and_skipping.bats │ │ │ │ │ ├── setup.bats │ │ │ │ │ ├── single_line.bats │ │ │ │ │ ├── skipped.bats │ │ │ │ │ ├── teardown.bats │ │ │ │ │ ├── test_helper.bash │ │ │ │ │ └── without_trailing_newline.bats │ │ │ │ └── suite │ │ │ │ │ ├── empty │ │ │ │ │ └── .gitkeep │ │ │ │ │ ├── multiple │ │ │ │ │ ├── a.bats │ │ │ │ │ └── b.bats │ │ │ │ │ └── single │ │ │ │ │ └── test.bats │ │ │ │ ├── suite.bats │ │ │ │ └── test_helper.bash │ │ │ ├── test.bats │ │ │ └── test_helper.bash │ └── test-chain-guide │ │ ├── cdp.js │ │ ├── cdp.test.js │ │ ├── package.json │ │ └── test-chain-guide.md ├── mcd │ ├── mcd-seth-cdp-manager │ │ ├── mcd-seth-cdp-manager.MD │ │ └── test │ │ │ ├── account │ │ │ ├── mcd-cli-test-keystore │ │ │ └── pass │ │ │ ├── libs │ │ │ ├── bats-assert │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── load.bash │ │ │ │ ├── package.json │ │ │ │ ├── script │ │ │ │ │ └── install-bats.sh │ │ │ │ ├── src │ │ │ │ │ └── assert.bash │ │ │ │ └── test │ │ │ │ │ ├── 50-assert-11-assert.bats │ │ │ │ │ ├── 50-assert-12-assert_equal.bats │ │ │ │ │ ├── 50-assert-13-assert_success.bats │ │ │ │ │ ├── 50-assert-14-assert_failure.bats │ │ │ │ │ ├── 50-assert-15-assert_output.bats │ │ │ │ │ ├── 50-assert-16-refute_output.bats │ │ │ │ │ ├── 50-assert-17-assert_line.bats │ │ │ │ │ ├── 50-assert-18-refute_line.bats │ │ │ │ │ ├── 50-assert-19-refute.bats │ │ │ │ │ └── test_helper.bash │ │ │ ├── bats-support │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── load.bash │ │ │ │ ├── package.json │ │ │ │ ├── script │ │ │ │ │ └── install-bats.sh │ │ │ │ ├── src │ │ │ │ │ ├── error.bash │ │ │ │ │ ├── lang.bash │ │ │ │ │ └── output.bash │ │ │ │ └── test │ │ │ │ │ ├── 50-output-10-batslib_err.bats │ │ │ │ │ ├── 50-output-11-batslib_count_lines.bats │ │ │ │ │ ├── 50-output-12-batslib_is_single_line.bats │ │ │ │ │ ├── 50-output-13-batslib_get_max_single_line_key_width.bats │ │ │ │ │ ├── 50-output-14-batslib_print_kv_single.bats │ │ │ │ │ ├── 50-output-15-batslib_print_kv_multi.bats │ │ │ │ │ ├── 50-output-16-batslib_print_kv_single_or_multi.bats │ │ │ │ │ ├── 50-output-17-batslib_prefix.bats │ │ │ │ │ ├── 50-output-18-batslib_mark.bats │ │ │ │ │ ├── 50-output-19-batslib_decorate.bats │ │ │ │ │ ├── 51-error-10-fail.bats │ │ │ │ │ ├── 52-lang-10-batslib_is_caller.bats │ │ │ │ │ └── test_helper.bash │ │ │ └── bats │ │ │ │ ├── .gitattributes │ │ │ │ ├── .travis.yml │ │ │ │ ├── CONDUCT.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── bin │ │ │ │ └── bats │ │ │ │ ├── install.sh │ │ │ │ ├── libexec │ │ │ │ ├── bats │ │ │ │ ├── bats-exec-suite │ │ │ │ ├── bats-exec-test │ │ │ │ ├── bats-format-tap-stream │ │ │ │ └── bats-preprocess │ │ │ │ ├── man │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── bats.1 │ │ │ │ ├── bats.1.ronn │ │ │ │ ├── bats.7 │ │ │ │ └── bats.7.ronn │ │ │ │ ├── package.json │ │ │ │ └── test │ │ │ │ ├── bats.bats │ │ │ │ ├── fixtures │ │ │ │ ├── bats │ │ │ │ │ ├── dos_line.bats │ │ │ │ │ ├── empty.bats │ │ │ │ │ ├── environment.bats │ │ │ │ │ ├── failing.bats │ │ │ │ │ ├── failing_and_passing.bats │ │ │ │ │ ├── failing_helper.bats │ │ │ │ │ ├── failing_setup.bats │ │ │ │ │ ├── failing_teardown.bats │ │ │ │ │ ├── intact.bats │ │ │ │ │ ├── invalid_tap.bats │ │ │ │ │ ├── load.bats │ │ │ │ │ ├── loop_keep_IFS.bats │ │ │ │ │ ├── output.bats │ │ │ │ │ ├── passing.bats │ │ │ │ │ ├── passing_and_failing.bats │ │ │ │ │ ├── passing_and_skipping.bats │ │ │ │ │ ├── passing_failing_and_skipping.bats │ │ │ │ │ ├── setup.bats │ │ │ │ │ ├── single_line.bats │ │ │ │ │ ├── skipped.bats │ │ │ │ │ ├── teardown.bats │ │ │ │ │ ├── test_helper.bash │ │ │ │ │ └── without_trailing_newline.bats │ │ │ │ └── suite │ │ │ │ │ ├── empty │ │ │ │ │ └── .gitkeep │ │ │ │ │ ├── multiple │ │ │ │ │ ├── a.bats │ │ │ │ │ └── b.bats │ │ │ │ │ └── single │ │ │ │ │ └── test.bats │ │ │ │ ├── suite.bats │ │ │ │ └── test_helper.bash │ │ │ ├── test.bats │ │ │ └── test_helper.bash │ └── mcd-seth │ │ ├── mcd-seth.MD │ │ └── test │ │ ├── account │ │ ├── mcd-cli-test-keystore │ │ └── pass │ │ ├── libs │ │ ├── bats-assert │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── load.bash │ │ │ ├── package.json │ │ │ ├── script │ │ │ │ └── install-bats.sh │ │ │ ├── src │ │ │ │ └── assert.bash │ │ │ └── test │ │ │ │ ├── 50-assert-11-assert.bats │ │ │ │ ├── 50-assert-12-assert_equal.bats │ │ │ │ ├── 50-assert-13-assert_success.bats │ │ │ │ ├── 50-assert-14-assert_failure.bats │ │ │ │ ├── 50-assert-15-assert_output.bats │ │ │ │ ├── 50-assert-16-refute_output.bats │ │ │ │ ├── 50-assert-17-assert_line.bats │ │ │ │ ├── 50-assert-18-refute_line.bats │ │ │ │ ├── 50-assert-19-refute.bats │ │ │ │ └── test_helper.bash │ │ ├── bats-support │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── load.bash │ │ │ ├── package.json │ │ │ ├── script │ │ │ │ └── install-bats.sh │ │ │ ├── src │ │ │ │ ├── error.bash │ │ │ │ ├── lang.bash │ │ │ │ └── output.bash │ │ │ └── test │ │ │ │ ├── 50-output-10-batslib_err.bats │ │ │ │ ├── 50-output-11-batslib_count_lines.bats │ │ │ │ ├── 50-output-12-batslib_is_single_line.bats │ │ │ │ ├── 50-output-13-batslib_get_max_single_line_key_width.bats │ │ │ │ ├── 50-output-14-batslib_print_kv_single.bats │ │ │ │ ├── 50-output-15-batslib_print_kv_multi.bats │ │ │ │ ├── 50-output-16-batslib_print_kv_single_or_multi.bats │ │ │ │ ├── 50-output-17-batslib_prefix.bats │ │ │ │ ├── 50-output-18-batslib_mark.bats │ │ │ │ ├── 50-output-19-batslib_decorate.bats │ │ │ │ ├── 51-error-10-fail.bats │ │ │ │ ├── 52-lang-10-batslib_is_caller.bats │ │ │ │ └── test_helper.bash │ │ └── bats │ │ │ ├── .gitattributes │ │ │ ├── .travis.yml │ │ │ ├── CONDUCT.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── bin │ │ │ └── bats │ │ │ ├── install.sh │ │ │ ├── libexec │ │ │ ├── bats │ │ │ ├── bats-exec-suite │ │ │ ├── bats-exec-test │ │ │ ├── bats-format-tap-stream │ │ │ └── bats-preprocess │ │ │ ├── man │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── bats.1 │ │ │ ├── bats.1.ronn │ │ │ ├── bats.7 │ │ │ └── bats.7.ronn │ │ │ ├── package.json │ │ │ └── test │ │ │ ├── bats.bats │ │ │ ├── fixtures │ │ │ ├── bats │ │ │ │ ├── dos_line.bats │ │ │ │ ├── empty.bats │ │ │ │ ├── environment.bats │ │ │ │ ├── failing.bats │ │ │ │ ├── failing_and_passing.bats │ │ │ │ ├── failing_helper.bats │ │ │ │ ├── failing_setup.bats │ │ │ │ ├── failing_teardown.bats │ │ │ │ ├── intact.bats │ │ │ │ ├── invalid_tap.bats │ │ │ │ ├── load.bats │ │ │ │ ├── loop_keep_IFS.bats │ │ │ │ ├── output.bats │ │ │ │ ├── passing.bats │ │ │ │ ├── passing_and_failing.bats │ │ │ │ ├── passing_and_skipping.bats │ │ │ │ ├── passing_failing_and_skipping.bats │ │ │ │ ├── setup.bats │ │ │ │ ├── single_line.bats │ │ │ │ ├── skipped.bats │ │ │ │ ├── teardown.bats │ │ │ │ ├── test_helper.bash │ │ │ │ └── without_trailing_newline.bats │ │ │ └── suite │ │ │ │ ├── empty │ │ │ │ └── .gitkeep │ │ │ │ ├── multiple │ │ │ │ ├── a.bats │ │ │ │ └── b.bats │ │ │ │ └── single │ │ │ │ └── test.bats │ │ │ ├── suite.bats │ │ │ └── test_helper.bash │ │ ├── test.bats │ │ └── test_helper.bash └── package.json └── vault ├── README.md ├── cdp-manager-guide └── cdp-manager-guide.md ├── monitoring-collateral-types-and-vaults └── monitoring-collateral-types-and-vaults.md └── vault-integration-guide ├── img ├── DepositETH.png ├── GenerateDAI.png ├── OpenVaultGenerateDai.png ├── PayBackAllDAIAndWithdrawETH.png ├── PayBackDai.png ├── SetupDSProxy.png ├── SingleETHVaultUserFlow.png ├── WithdrawETH.png └── cdpguide-package.png ├── sequence-diagrams └── README.md └── vault-integration-guide.md /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | node_modules/ 6 | package-lock.json -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "MD013": false, 3 | "MD024": false, 4 | "MD033": false, 5 | "MD025": false 6 | } -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/CONTRIBUTING -------------------------------------------------------------------------------- /Oasis/intro-to-oasis/assets/cherry-order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/Oasis/intro-to-oasis/assets/cherry-order.png -------------------------------------------------------------------------------- /Oasis/intro-to-oasis/assets/cherry-transaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/Oasis/intro-to-oasis/assets/cherry-transaction.png -------------------------------------------------------------------------------- /Oasis/intro-to-oasis/assets/order-book-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/Oasis/intro-to-oasis/assets/order-book-1.png -------------------------------------------------------------------------------- /Oasis/intro-to-oasis/assets/order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/Oasis/intro-to-oasis/assets/order.png -------------------------------------------------------------------------------- /Oasis/intro-to-oasis/assets/sell-order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/Oasis/intro-to-oasis/assets/sell-order.png -------------------------------------------------------------------------------- /Oasis/intro-to-oasis/assets/transaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/Oasis/intro-to-oasis/assets/transaction.png -------------------------------------------------------------------------------- /dai/README.md: -------------------------------------------------------------------------------- 1 | # Dai 2 | 3 | The Dai stablecoin is a collateral-backed cryptocurrency whose value is stable relative to the US Dollar. It is currently live on the Ethereum network as an ERC20 token. 4 | 5 | ## Getting Started 6 | 7 | ## Beginner 8 | 9 | [Dai Token](/dai/dai-token/dai-token.md) 10 | 11 | [Dai in Smart Contracts](/dai/dai-in-smart-contracts/dai-in-smart-contracts.md) 12 | 13 | [DsrManager documentation](/dai/dsr-manager-docs/dsr-manager-docs.md) 14 | 15 | ## Intermediate 16 | 17 | [Tracking Dai Supply](/dai/dai-supply/dai-supply.md) 18 | 19 | [DSR Integration Guide](/dai/dsr-integration-guide/dsr-integration-guide.md) 20 | 21 | <<<<<<< HEAD 22 | ======= 23 | [Permit Function](/dai/how-to-use-permit-function/how-to-use-permit-function.md) 24 | 25 | >>>>>>> 3c16340bc37c925b6e78e4f67975cbba889799a2 26 | ## Advanced 27 | -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/CompileVersion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/CompileVersion.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/DaiFaucet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/DaiFaucet.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/Deploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/Deploy.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/FullContract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/FullContract.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/Interact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/Interact.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/Successfull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/Successfull.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/compiled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/compiled.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/pasteCode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/pasteCode.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/verify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/verify.png -------------------------------------------------------------------------------- /dai/dai-in-smart-contracts/images/verifyAndPublish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-in-smart-contracts/images/verifyAndPublish.png -------------------------------------------------------------------------------- /dai/dai-supply/images/dai_venn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/dai/dai-supply/images/dai_venn.png -------------------------------------------------------------------------------- /dai/dsr-integration-guide/dsr.sol: -------------------------------------------------------------------------------- 1 | /** 2 | DO NOT USE THIS CODE IN PRODUCTION 3 | THIS IS A DRAFT EXAMPLE OF HOW TO INTERACT WITH THE MAKER PROTOCOL POT CONTRACT 4 | THIS CODE HAS NOT BEEN TESTED 5 | */ 6 | 7 | pragma solidity >=0.5.12; 8 | 9 | contract PotLike { 10 | function chi() external view returns (uint256); 11 | function rho() external returns (uint256); 12 | function drip() external returns (uint256); 13 | function join(uint256) external; 14 | function exit(uint256) external; 15 | function pie(address) public view returns (uint256); 16 | 17 | } 18 | 19 | contract JoinLike { 20 | function join(address, uint256) external; 21 | function exit(address, uint256) external; 22 | function vat() public returns (VatLike); 23 | function dai() public returns (GemLike); 24 | 25 | } 26 | 27 | contract GemLike { 28 | function transferFrom(address,address,uint256) external returns (bool); 29 | function approve(address,uint256) external returns (bool); 30 | } 31 | 32 | contract VatLike { 33 | function hope(address) external; 34 | function dai(address) public view returns (uint256); 35 | 36 | } 37 | 38 | contract DSR { 39 | 40 | // Contract interfaces 41 | PotLike public pot; 42 | JoinLike public daiJoin; 43 | GemLike public daiToken; 44 | VatLike public vat; 45 | 46 | address owner; 47 | 48 | 49 | // Supporting Math functions 50 | uint256 constant RAY = 10 ** 27; 51 | function add(uint256 x, uint256 y) internal pure returns (uint256 z) { 52 | require((z = x + y) >= x); 53 | } 54 | function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { 55 | require((z = x - y) <= x); 56 | } 57 | function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { 58 | require(y == 0 || (z = x * y) / y == x); 59 | } 60 | 61 | constructor(address pot_, address join_, address dai_, address vat_) public { 62 | owner = msg.sender; 63 | pot = PotLike(pot_); 64 | daiJoin = JoinLike(join_); 65 | daiToken = GemLike(dai_); 66 | vat = VatLike(vat_); 67 | 68 | vat.hope(join_); 69 | vat.hope(pot_); 70 | 71 | daiToken.approve(join_, uint256(-1)); 72 | } 73 | 74 | modifier onlyOwner { 75 | require(msg.sender == owner, 76 | "Only the contract owner can call this function"); 77 | _; 78 | } 79 | 80 | function join(uint256 wad) public onlyOwner { 81 | uint256 chi = (now > pot.rho()) ? pot.drip() : pot.chi(); 82 | daiToken.transferFrom(msg.sender, address(this), wad); 83 | daiJoin.join(address(this), wad); 84 | pot.join(mul(wad, RAY) / chi); 85 | } 86 | 87 | function exit(uint256 wad) public onlyOwner { 88 | uint256 chi = (now > pot.rho()) ? pot.drip() : pot.chi(); 89 | pot.exit(mul(wad, RAY) / chi); 90 | daiJoin.exit(msg.sender, daiJoin.vat().dai(address(this)) / RAY); 91 | } 92 | 93 | function exitAll() public onlyOwner { 94 | if (now > pot.rho()) pot.drip(); 95 | pot.exit(pot.pie(address(this))); 96 | daiJoin.exit(msg.sender, daiJoin.vat().dai(address(this)) / RAY); 97 | } 98 | 99 | function balance() public view returns (uint256) { 100 | uint256 pie = pot.pie(address(this)); 101 | uint256 chi = pot.chi(); 102 | return pie * chi / RAY; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /dai/dsr-integration-guide/dsrManagerExample.sol: -------------------------------------------------------------------------------- 1 | /** 2 | DO NOT USE THIS CODE IN PRODUCTION 3 | THIS IS A DRAFT EXAMPLE OF HOW TO INTERACT WITH THE MAKER PROTOCOL POT CONTRACT 4 | THIS CODE HAS NOT BEEN TESTED 5 | */ 6 | 7 | pragma solidity ^0.5.12; 8 | 9 | //Setting up DsrManager and Dai token contract interfaces 10 | contract DsrManager { 11 | function daiBalance(address usr) external returns (uint256 wad); 12 | function join(address dst, uint256 wad) external; 13 | function exit(address dst, uint256 wad) external; 14 | function exitAll(address dst) external; 15 | } 16 | 17 | contract GemLike { 18 | function transferFrom(address,address,uint) external returns (bool); 19 | function approve(address,uint) external returns (bool); 20 | } 21 | 22 | contract DsrExample { 23 | 24 | // Contract Interfaces 25 | DsrManager public dsrM; 26 | GemLike public daiToken; 27 | 28 | address owner; 29 | 30 | event DaiBalance(address indexed src, uint balance); 31 | 32 | //Instantiating DsrExample contract with 33 | //DsrManager contract address 34 | //Dai Token contract address 35 | //Setting msg.sender as owner of contract 36 | constructor(address dsrM_, address dai_ ) public { 37 | dsrM = DsrManager(dsrM_); 38 | daiToken = GemLike(dai_); 39 | owner = msg.sender; 40 | 41 | //Approving DsrManager to withdraw Dai from this contract 42 | daiToken.approve(address(dsrM), uint256(-1)); 43 | 44 | } 45 | 46 | //Access restriction function 47 | //It only allows owner of contract to call functions 48 | modifier onlyOwner { 49 | require(msg.sender == owner, 50 | "Only the contract owner can call this function"); 51 | _; 52 | } 53 | 54 | //Join Dai in DSR 55 | function activateDsr(uint wad) public onlyOwner { 56 | daiToken.transferFrom(msg.sender, address(this), wad); 57 | dsrM.join(address(this), wad); 58 | } 59 | 60 | //Withdraw a certain amount of Dai from DSR 61 | function exitDsr(address dst, uint256 wad) public onlyOwner { 62 | dsrM.exit(dst, wad); 63 | } 64 | 65 | //Withdraw all Dai from DSR 66 | function exitDsrAll(address dst) public onlyOwner { 67 | dsrM.exitAll(dst); 68 | } 69 | 70 | //Check DAI + earned Dai balance in DSR 71 | function DsrBalance() public returns (uint wad) { 72 | uint balance = dsrM.daiBalance(address(this)); 73 | emit DaiBalance(address(this), balance); 74 | return balance; 75 | } 76 | } -------------------------------------------------------------------------------- /devtools/README.md: -------------------------------------------------------------------------------- 1 | # Development Tools 2 | 3 | Guides for tools and libraries developed at Maker 4 | 5 | ## Getting Started 6 | 7 | ## Beginner 8 | 9 | ## Intermediate 10 | 11 | - [Dai.js - How to build Dai.js wallet plugin](./Dai.js/How-to-build-dai-js-wallet-plugin.md) 12 | - [Test Chain Guide](/devtools/test-chain-guide/test-chain-guide.md) 13 | - [Introduction to Seth](/devtools/seth/seth-guide-01/seth-guide-01.md) 14 | 15 | ## Advanced 16 | 17 | [Working with DSProxy](/devtools/working-with-dsproxy/working-with-dsproxy.md) 18 | -------------------------------------------------------------------------------- /exchanges/README.md: -------------------------------------------------------------------------------- 1 | # Exchanges 2 | 3 | This folder contains guides specifically for exchanges seeking to integrate with the Maker Protocol. 4 | 5 | ## Quick start 6 | 7 | If you are already familiar with Ethereum, the ERC-20 token standard, and Solidity smart contracts, you can checkout this guide for listing DAI and MKR tokens: 8 | 9 | - [Quick guide for listing DAI and MKR tokens](/exchanges/exchanges-guide/exchanges-guide.md) 10 | 11 | -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/NestedMultiSig.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/NestedMultiSig.jpg -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 1.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 2.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 3.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 4.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 5.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 6.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 7.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 8.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled 9.png -------------------------------------------------------------------------------- /gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/nested-multisig-gnosis-safe-wallet-setup-walkthrough/pictures/Untitled.png -------------------------------------------------------------------------------- /gnosis-multisig/vote-proxy-setup-gnosis-multisig/pictures/proxyFactory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/vote-proxy-setup-gnosis-multisig/pictures/proxyFactory.png -------------------------------------------------------------------------------- /gnosis-multisig/vote-proxy-setup-gnosis-multisig/pictures/proxycontract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/vote-proxy-setup-gnosis-multisig/pictures/proxycontract.png -------------------------------------------------------------------------------- /gnosis-multisig/vote-proxy-setup-gnosis-multisig/pictures/voteFront.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/gnosis-multisig/vote-proxy-setup-gnosis-multisig/pictures/voteFront.png -------------------------------------------------------------------------------- /governance/README.md: -------------------------------------------------------------------------------- 1 | # Governance 2 | 3 | This folder contains guides for integration with Maker Governance systems, which include but are not limited to the following smart contracts: DSChief, Vote-Proxy, etc. 4 | 5 | ## Getting Started 6 | 7 | ## Beginner 8 | 9 | ## Intermediate 10 | 11 | - [Vote Proxy Setup: Air-gapped Machine](/governance/vote-proxy-setup-airgapped-machine/vote-proxy-setup-airgapped-machine.md) 12 | - [Emergency Shutdown (ES) CLI Documentation](https://github.com/makerdao/developerguides/blob/master/governance/Emergency-Shutdown-CLI-Documentation.md) 13 | - [Collateral Redemption during Emergency Shutdown Guide](https://github.com/makerdao/developerguides/blob/master/governance/Collateral%20Redemption%20during%20Emergency%20Shutdown.md) 14 | 15 | ## Advanced 16 | -------------------------------------------------------------------------------- /governance/vote-proxy-setup-airgapped-machine/pictures/lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/governance/vote-proxy-setup-airgapped-machine/pictures/lock.png -------------------------------------------------------------------------------- /governance/vote-proxy-setup-airgapped-machine/pictures/lockmkr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/governance/vote-proxy-setup-airgapped-machine/pictures/lockmkr.png -------------------------------------------------------------------------------- /governance/vote-proxy-setup-airgapped-machine/pictures/proxycontract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/governance/vote-proxy-setup-airgapped-machine/pictures/proxycontract.png -------------------------------------------------------------------------------- /governance/vote-proxy-setup-airgapped-machine/pictures/voteFront.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/governance/vote-proxy-setup-airgapped-machine/pictures/voteFront.png -------------------------------------------------------------------------------- /governance/vote-proxy-setup-airgapped-machine/pictures/voteproxyfactory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/governance/vote-proxy-setup-airgapped-machine/pictures/voteproxyfactory.png -------------------------------------------------------------------------------- /keepers/simple-arbitrage-keeper/pictures/lifecycle.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/keepers/simple-arbitrage-keeper/pictures/lifecycle.jpeg -------------------------------------------------------------------------------- /market-makers/market-makers.md: -------------------------------------------------------------------------------- 1 | # Market Makers 2 | 3 | - [Market Makers](#market-makers) 4 | - [Prerequisites](#prerequisites) 5 | - [Market Maker Keeper repos](#market-maker-keeper-repos) 6 | - [Market Maker Keeper](#market-maker-keeper) 7 | - [Market Maker Stats](#market-maker-stats) 8 | - [Pymaker](#pymaker) 9 | - [Additional source code and developer docs](#additional-source-code-and-developer-docs) 10 | - [Need help](#need-help) 11 | 12 | This document contains the necessary resources for partners to implement Keepers for Market Making. 13 | 14 | ## Prerequisites 15 | 16 | This document assumes familiarity with Ethereum, and in-depth knowledge of the Maker platform. 17 | 18 | ## Market Maker Keeper repos 19 | 20 | ### [Market Maker Keeper](https://github.com/makerdao/market-maker-keeper) 21 | 22 | This repository contains a set of Keepers that have been implemented to facilitate market making on a specific set of decentralized exchanges. While implemented specifically to work on specific exchanges, all Keepers in the repo share logic and operate similarly, as they all rely on creating a series of orders in preconfigured “bands”. 23 | 24 | ### [Market Maker Stats](https://github.com/makerdao/market-maker-stats) 25 | 26 | Market Maker Stats provides a set of tools for visualizing market making data for a set of decentralized exchanges. These tools include: 27 | 28 | - Trade chart tools for showing historical market prices and recent Keeper trades. 29 | - Profitability calculation tools for calculating profitability of ETH/DAI or BTC/DAI keepers. 30 | - Trade history dumping tools for exporting lists of recent trades. 31 | 32 | ### [Pymaker](https://github.com/makerdao/pymaker) 33 | 34 | Pymaker is a Python API which provides endpoints to interact with the Maker smart contracts. It exposes most of the functionality of the Maker platform, but most importantly for this guide it can be used to create Keepers. This library can be used to create custom market making Keepers. 35 | 36 | ## Additional source code and developer docs 37 | 38 | **More resources on Keepers:** 39 | 40 | - 41 | 42 | **Running a Keeper node:** 43 | 44 | - [https://github.com/makerdao/keeper-node](https://github.com/makerdao/keeper-node) 45 | 46 | **Current live Multi Collateral Dai:** 47 | 48 | - Docs: [https://github.com/makerdao/dss/blob/master/DEVELOPING.md](https://github.com/makerdao/dss/blob/master/DEVELOPING.md) 49 | - Wiki: [https://github.com/makerdao/dss/wiki](https://github.com/makerdao/dss/wiki) 50 | - Source: [https://github.com/makerdao/dss](https://github.com/makerdao/dss) 51 | 52 | **Single Collateral Dai credit system implementation:** 53 | 54 | - Docs: [https://developer.makerdao.com/dai/1/api/](https://developer.makerdao.com/dai/1/api/) 55 | - Docs: [https://github.com/makerdao/sai/blob/master/DEVELOPING.md](https://github.com/makerdao/sai/blob/master/DEVELOPING.md) 56 | - Source: [https://github.com/makerdao/sai](https://github.com/makerdao/sai) 57 | 58 | **DSToken (token standard for Maker tokens):** 59 | 60 | - Docs: [https://dapp.tools/dappsys/ds-token.html](https://dapp.tools/dappsys/ds-token.html) 61 | - Source: [https://github.com/dapphub/ds-token](https://github.com/dapphub/ds-token) 62 | 63 | **Maker Protocol in general:** 64 | 65 | - [Whitepaper](https://makerdao.com/whitepaper/) 66 | 67 | ## Need help 68 | 69 | - Rocket chat - [#dev](https://chat.makerdao.com/channel/dev) channel 70 | -------------------------------------------------------------------------------- /mcd/README.md: -------------------------------------------------------------------------------- 1 | # Multi-Collateral Dai 2 | 3 | This repo contains guides for interacting and integrating with Multi-Collateral Dai (MCD) -- the next version of the Maker platform. 4 | 5 | ## Guides in this repo 6 | 7 | - [Introduction and Overview of Maker Protocol](/mcd/mcd-101/mcd-101.md) 8 | - [Using MCD-CLI to create and close a Vault on Kovan](/mcd/mcd-cli/mcd-cli-guide-01/mcd-cli-guide-01.md) 9 | - [Using Seth to create and close a Vault on Goerli](/mcd/mcd-seth/mcd-seth.md) 10 | - [Upgrading to MCD - overview for different partners](/mcd/upgrading-to-multi-collateral-dai/upgrading-to-multi-collateral-dai.md) 11 | - [Add a new collateral type - Kovan](/mcd/add-collateral-type-testnet/add-collateral-type-testnet.md) 12 | - [Intro to the Rate mechanism](/mcd/intro-rate-mechanism/intro-rate-mechanism.md) 13 | - [Collateral Auction Integration Guide](mcd/collateral-auction-integration-guide/collateral-auction-integration-guide.md) 14 | - [MCD deplyoment guide](/mcd/mcd-deplyoment/mcd-deployment.md) 15 | -------------------------------------------------------------------------------- /mcd/mcd-101/mcd-101.md: -------------------------------------------------------------------------------- 1 | # MCD 101 2 | 3 | A comprehensive overview of the smart contracts within the Maker Protocol. 4 | 5 | This previous information here was outdated. [Here is a link to our current overview](https://docs.makerdao.com/maker-protocol-101) 6 | -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/50_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/50_1.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/50_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/50_2.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/51_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/51_1.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/51_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/51_2.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/51_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/51_3.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/CDP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/CDP.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/Proxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/Proxy.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/SRupdated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/SRupdated.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/assetStates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/assetStates.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/auction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/auction.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/bitcoinChart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/bitcoinChart.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/cdps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/cdps.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/cdpstates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/cdpstates.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/daiDrawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/daiDrawn.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/daipeg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/daipeg.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/governance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/governance.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/house.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/house.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/idealactrate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/idealactrate.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/interactionD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/interactionD.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/oracle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/oracle.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/smartContracts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/smartContracts.png -------------------------------------------------------------------------------- /mcd/mcd-101/pictures/supplyDemand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/mcd-101/pictures/supplyDemand.png -------------------------------------------------------------------------------- /mcd/upgrading-to-multi-collateral-dai/figures/cdpmigration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/upgrading-to-multi-collateral-dai/figures/cdpmigration.png -------------------------------------------------------------------------------- /mcd/upgrading-to-multi-collateral-dai/figures/exchangedaimigration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/upgrading-to-multi-collateral-dai/figures/exchangedaimigration.png -------------------------------------------------------------------------------- /mcd/upgrading-to-multi-collateral-dai/figures/migrating10sai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/upgrading-to-multi-collateral-dai/figures/migrating10sai.png -------------------------------------------------------------------------------- /mcd/upgrading-to-multi-collateral-dai/figures/saimigration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/upgrading-to-multi-collateral-dai/figures/saimigration.png -------------------------------------------------------------------------------- /mcd/upgrading-to-multi-collateral-dai/figures/saimigrationfunctions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/upgrading-to-multi-collateral-dai/figures/saimigrationfunctions.png -------------------------------------------------------------------------------- /mcd/upgrading-to-multi-collateral-dai/figures/userflowexchange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/mcd/upgrading-to-multi-collateral-dai/figures/userflowexchange.png -------------------------------------------------------------------------------- /sample/sample-guide/sample-guide.md: -------------------------------------------------------------------------------- 1 | # Title 2 | 3 | Level: Beginner/Intermediate/Advanced 4 | Estimated Time: X minutes 5 | 6 | ## Overview 7 | 8 | ## Learning objectives 9 | 10 | ## Pre-requisites 11 | 12 | ## Content / Sections 13 | 14 | ## Summary 15 | 16 | ## Troubleshooting 17 | 18 | ## Next steps 19 | 20 | Other guides can be listed here 21 | 22 | ## Resources 23 | 24 | API and SDK documentation, Code Samples, ... 25 | -------------------------------------------------------------------------------- /tests/README.MD: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | This folder is intended to keep track of any breaking changes in the source code that resides in our guides. 4 | If a test fails, we need to update the code or dependencies where relevant. 5 | 6 | ## Available tests 7 | 8 | - [mcd-cli](./devtools/mcd-cli/mcd-cli.MD) 9 | - [test-chain-guide](./devtools/test-chain-guide/test-chain-guide.md) 10 | - [mcd-seth](./mcd/mcd-seth/mcd-seth.MD) 11 | - [mcd-set-cdp-manager](./mcd/mcd-seth-cdp-manager/mcd-seth-cdp-manager.MD) 12 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/mcd-cli.MD: -------------------------------------------------------------------------------- 1 | # MCD-CLI Test 2 | 3 | *Version: [0.2.10](https://changelog.makerdao.com/releases/0.2.10/index.html) kovan deployment* 4 | 5 | This test checks the [mcd-cli guide](https://github.com/makerdao/developerguides/blob/master/devtools/mcd-cli/mcd-cli-guide-01/mcd-cli-guide-01.md) against the mcd-cli tool to see if there's any breaking changes. 6 | The `test` folder has necessary files to run the test. 7 | 8 | Make sure to install the [mcd-cli](https://github.com/makerdao/mcd-cli) tool first before running the test. 9 | 10 | ## Install 11 | 12 | - Linux: `sudo apt install bats` 13 | - Mac: 14 | - Press Command+Space and type Terminal and press enter/return key. 15 | - Run in Terminal app: 16 | `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null` 17 | and press enter/return key. 18 | If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish. 19 | - Run: `brew install bats` 20 | 21 | ## Steps 22 | 23 | - Navigate to `test` folder 24 | - To run the tests, run `bats test.bats` command and the test will start. 25 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/account/mcd-cli-test-keystore: -------------------------------------------------------------------------------- 1 | {"version":3,"id":"93dd8afb-9925-4622-ae37-4c70d642bb08","address":"18d92ba0b79d769e6b781b92ee2e9d45b3e1e017","crypto":{"ciphertext":"cb90ef46af693ed78da0741f9c03164a8b6773e6db207f9d35624b7e026bc720","cipherparams":{"iv":"2baf3504d167e0c0eeffb499e4b717f6"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"57f47ef42d6ef6f04f7309decf7e7819ff582ed228bcffe9be7ce537c384c9b5","n":8192,"r":8,"p":1},"mac":"ae38a6d51d1bad1230e0ec6de69c6d911810c24d4412d3e2d8560b185a24b799"}} -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/account/pass: -------------------------------------------------------------------------------- 1 | mcd-cli-test 2 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_install: 3 | - ./script/install-bats.sh 4 | - git clone --depth 1 https://github.com/ztombol/bats-support ../bats-support 5 | before_script: 6 | - export PATH="${HOME}/.local/bin:${PATH}" 7 | script: 8 | - bats test 9 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 7 | ## [0.3.0] - 2016-03-22 8 | 9 | ### Removed 10 | 11 | - Move `fail()` to `bats-support` 12 | 13 | 14 | ## [0.2.0] - 2016-03-11 15 | 16 | ### Added 17 | 18 | - `refute()` to complement `assert()` 19 | - `npm` support 20 | 21 | ### Fixed 22 | 23 | - Not consuming the `--` when stopping option parsing in 24 | `assert_output`, `refute_output`, `assert_line` and `refute_line` 25 | 26 | 27 | ## 0.1.0 - 2016-02-16 28 | 29 | ### Added 30 | 31 | - Reporting arbitrary failures with `fail()` 32 | - Generic assertions with `assert()` and `assert_equal()` 33 | - Testing exit status with `assert_success()` and `assert_failure()` 34 | - Testing output with `assert_output()` and `refute_output()` 35 | - Testing individual lines with `assert_line()` and `refute_line()` 36 | 37 | 38 | [0.3.0]: https://github.com/ztombol/bats-assert/compare/v0.2.0...v0.3.0 39 | [0.2.0]: https://github.com/ztombol/bats-assert/compare/v0.1.0...v0.2.0 40 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash" 2 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats-assert", 3 | "version": "0.3.0", 4 | "private": true, 5 | "peerDependencies": { 6 | "bats-support": "git+https://github.com/ztombol/bats-support.git#v0.2.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/script/install-bats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o xtrace 4 | 5 | git clone --depth 1 https://github.com/sstephenson/bats 6 | cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats 7 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/test/50-assert-11-assert.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'assert() : returns 0 if evaluates to TRUE' { 6 | run assert true 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'assert() : returns 1 and displays if it evaluates to FALSE' { 12 | run assert false 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 3 ] 15 | [ "${lines[0]}" == '-- assertion failed --' ] 16 | [ "${lines[1]}" == 'expression : false' ] 17 | [ "${lines[2]}" == '--' ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/test/50-assert-12-assert_equal.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'assert_equal() : returns 0 if equals ' { 6 | run assert_equal 'a' 'a' 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'assert_equal() : returns 1 and displays details if does not equal ' { 12 | run assert_equal 'a' 'b' 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 4 ] 15 | [ "${lines[0]}" == '-- values do not equal --' ] 16 | [ "${lines[1]}" == 'expected : b' ] 17 | [ "${lines[2]}" == 'actual : a' ] 18 | [ "${lines[3]}" == '--' ] 19 | } 20 | 21 | @test 'assert_equal() : displays details in multi-line format if is longer than one line' { 22 | run assert_equal $'a 0\na 1' 'b' 23 | [ "$status" -eq 1 ] 24 | [ "${#lines[@]}" -eq 7 ] 25 | [ "${lines[0]}" == '-- values do not equal --' ] 26 | [ "${lines[1]}" == 'expected (1 lines):' ] 27 | [ "${lines[2]}" == ' b' ] 28 | [ "${lines[3]}" == 'actual (2 lines):' ] 29 | [ "${lines[4]}" == ' a 0' ] 30 | [ "${lines[5]}" == ' a 1' ] 31 | [ "${lines[6]}" == '--' ] 32 | } 33 | 34 | @test 'assert_equal() : displays details in multi-line format if is longer than one line' { 35 | run assert_equal 'a' $'b 0\nb 1' 36 | [ "$status" -eq 1 ] 37 | [ "${#lines[@]}" -eq 7 ] 38 | [ "${lines[0]}" == '-- values do not equal --' ] 39 | [ "${lines[1]}" == 'expected (2 lines):' ] 40 | [ "${lines[2]}" == ' b 0' ] 41 | [ "${lines[3]}" == ' b 1' ] 42 | [ "${lines[4]}" == 'actual (1 lines):' ] 43 | [ "${lines[5]}" == ' a' ] 44 | [ "${lines[6]}" == '--' ] 45 | } 46 | 47 | @test 'assert_equal() : performs literal matching' { 48 | run assert_equal 'a' '*' 49 | [ "$status" -eq 1 ] 50 | } 51 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/test/50-assert-13-assert_success.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test "assert_success(): returns 0 if \`\$status' is 0" { 6 | run true 7 | run assert_success 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 0 ] 10 | } 11 | 12 | @test "assert_success(): returns 1 and displays details if \`\$status' is not 0" { 13 | run bash -c 'echo "a" 14 | exit 1' 15 | run assert_success 16 | [ "$status" -eq 1 ] 17 | [ "${#lines[@]}" -eq 4 ] 18 | [ "${lines[0]}" == '-- command failed --' ] 19 | [ "${lines[1]}" == 'status : 1' ] 20 | [ "${lines[2]}" == 'output : a' ] 21 | [ "${lines[3]}" == '--' ] 22 | } 23 | 24 | @test "assert_success(): displays \`\$output' in multi-line format if it is longer than one line" { 25 | run bash -c 'printf "a 0\na 1" 26 | exit 1' 27 | run assert_success 28 | [ "$status" -eq 1 ] 29 | [ "${#lines[@]}" -eq 6 ] 30 | [ "${lines[0]}" == '-- command failed --' ] 31 | [ "${lines[1]}" == 'status : 1' ] 32 | [ "${lines[2]}" == 'output (2 lines):' ] 33 | [ "${lines[3]}" == ' a 0' ] 34 | [ "${lines[4]}" == ' a 1' ] 35 | [ "${lines[5]}" == '--' ] 36 | } 37 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/test/50-assert-14-assert_failure.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test "assert_failure(): returns 0 if \`\$status' is not 0" { 6 | run false 7 | run assert_failure 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 0 ] 10 | } 11 | 12 | @test "assert_failure(): returns 1 and displays details if \`\$status' is 0" { 13 | run bash -c 'echo "a" 14 | exit 0' 15 | run assert_failure 16 | [ "$status" -eq 1 ] 17 | [ "${#lines[@]}" -eq 3 ] 18 | [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] 19 | [ "${lines[1]}" == 'output : a' ] 20 | [ "${lines[2]}" == '--' ] 21 | } 22 | 23 | @test "assert_failure(): displays \`\$output' in multi-line format if it is longer then one line" { 24 | run bash -c 'printf "a 0\na 1" 25 | exit 0' 26 | run assert_failure 27 | [ "$status" -eq 1 ] 28 | [ "${#lines[@]}" -eq 5 ] 29 | [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] 30 | [ "${lines[1]}" == 'output (2 lines):' ] 31 | [ "${lines[2]}" == ' a 0' ] 32 | [ "${lines[3]}" == ' a 1' ] 33 | [ "${lines[4]}" == '--' ] 34 | } 35 | 36 | @test "assert_failure() : returns 0 if \`\$status' equals " { 37 | run bash -c 'exit 1' 38 | run assert_failure 1 39 | [ "$status" -eq 0 ] 40 | [ "${#lines[@]}" -eq 0 ] 41 | } 42 | 43 | @test "assert_failure() : returns 1 and displays details if \`\$status' does not equal " { 44 | run bash -c 'echo "a" 45 | exit 1' 46 | run assert_failure 2 47 | [ "$status" -eq 1 ] 48 | [ "${#lines[@]}" -eq 5 ] 49 | [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] 50 | [ "${lines[1]}" == 'expected : 2' ] 51 | [ "${lines[2]}" == 'actual : 1' ] 52 | [ "${lines[3]}" == 'output : a' ] 53 | [ "${lines[4]}" == '--' ] 54 | } 55 | 56 | @test "assert_failure() : displays \`\$output' in multi-line format if it is longer then one line" { 57 | run bash -c 'printf "a 0\na 1" 58 | exit 1' 59 | run assert_failure 2 60 | [ "$status" -eq 1 ] 61 | [ "${#lines[@]}" -eq 7 ] 62 | [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] 63 | [ "${lines[1]}" == 'expected : 2' ] 64 | [ "${lines[2]}" == 'actual : 1' ] 65 | [ "${lines[3]}" == 'output (2 lines):' ] 66 | [ "${lines[4]}" == ' a 0' ] 67 | [ "${lines[5]}" == ' a 1' ] 68 | [ "${lines[6]}" == '--' ] 69 | } 70 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/test/50-assert-19-refute.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'refute() : returns 0 if evaluates to FALSE' { 6 | run refute false 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'refute() : returns 1 and displays if it evaluates to TRUE' { 12 | run refute true 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 3 ] 15 | [ "${lines[0]}" == '-- assertion succeeded, but it was expected to fail --' ] 16 | [ "${lines[1]}" == 'expression : true' ] 17 | [ "${lines[2]}" == '--' ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-assert/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." 3 | export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}" 4 | 5 | # Load dependencies. 6 | load "${TEST_DEPS_DIR}/bats-support/load.bash" 7 | 8 | # Load library. 9 | load '../load' 10 | } 11 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_install: 3 | - ./script/install-bats.sh 4 | before_script: 5 | - export PATH="${HOME}/.local/bin:${PATH}" 6 | script: 7 | - bats test 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 7 | ## [0.3.0] - 2016-11-29 8 | 9 | ### Added 10 | 11 | - Restricting invocation to specific locations with 12 | `batslib_is_caller()` 13 | 14 | 15 | ## [0.2.0] - 2016-03-22 16 | 17 | ### Added 18 | 19 | - `npm` support 20 | - Reporting arbitrary failures with `fail()` (moved from `bats-assert`) 21 | 22 | ### Changed 23 | 24 | - Library renamed to `bats-support` 25 | 26 | 27 | ## 0.1.0 - 2016-02-16 28 | 29 | ### Added 30 | 31 | - Two-column key-value formatting with `batslib_print_kv_single()` 32 | - Multi-line key-value formatting with `batslib_print_kv_multi()` 33 | - Mixed formatting with `batslib_print_kv_single_or_multi()` 34 | - Header and footer decoration with `batslib_decorate()` 35 | - Prefixing lines with `batslib_prefix()` 36 | - Marking lines with `batslib_mark()` 37 | - Common output function `batslib_err()` 38 | - Line counting with `batslib_count_lines()` 39 | - Checking whether a text is one line long with 40 | `batslib_is_single_line()` 41 | - Determining key width for two-column and mixed formatting with 42 | `batslib_get_max_single_line_key_width()` 43 | 44 | 45 | [0.3.0]: https://github.com/ztombol/bats-support/compare/v0.2.0...v0.3.0 46 | [0.2.0]: https://github.com/ztombol/bats-support/compare/v0.1.0...v0.2.0 47 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" 2 | source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" 3 | source "$(dirname "${BASH_SOURCE[0]}")/src/lang.bash" 4 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats-support", 3 | "version": "0.3.0", 4 | "private": true 5 | } 6 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/script/install-bats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o xtrace 4 | 5 | git clone --depth 1 https://github.com/sstephenson/bats 6 | cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats 7 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/src/error.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-support - Supporting library for Bats test helpers 3 | # 4 | # Written in 2016 by Zoltan Tombol 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # . 14 | # 15 | 16 | # 17 | # error.bash 18 | # ---------- 19 | # 20 | # Functions implementing error reporting. Used by public helper 21 | # functions or test suits directly. 22 | # 23 | 24 | # Fail and display a message. When no parameters are specified, the 25 | # message is read from the standard input. Other functions use this to 26 | # report failure. 27 | # 28 | # Globals: 29 | # none 30 | # Arguments: 31 | # $@ - [=STDIN] message 32 | # Returns: 33 | # 1 - always 34 | # Inputs: 35 | # STDIN - [=$@] message 36 | # Outputs: 37 | # STDERR - message 38 | fail() { 39 | (( $# == 0 )) && batslib_err || batslib_err "$@" 40 | return 1 41 | } 42 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/src/lang.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-util - Various auxiliary functions for Bats 3 | # 4 | # Written in 2016 by Zoltan Tombol 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # . 14 | # 15 | 16 | # 17 | # lang.bash 18 | # --------- 19 | # 20 | # Bash language and execution related functions. Used by public helper 21 | # functions. 22 | # 23 | 24 | # Check whether the calling function was called from a given function. 25 | # 26 | # By default, direct invocation is checked. The function succeeds if the 27 | # calling function was called directly from the given function. In other 28 | # words, if the given function is the next element on the call stack. 29 | # 30 | # When `--indirect' is specified, indirect invocation is checked. The 31 | # function succeeds if the calling function was called from the given 32 | # function with any number of intermediate calls. In other words, if the 33 | # given function can be found somewhere on the call stack. 34 | # 35 | # Direct invocation is a form of indirect invocation with zero 36 | # intermediate calls. 37 | # 38 | # Globals: 39 | # FUNCNAME 40 | # Options: 41 | # -i, --indirect - check indirect invocation 42 | # Arguments: 43 | # $1 - calling function's name 44 | # Returns: 45 | # 0 - current function was called from the given function 46 | # 1 - otherwise 47 | batslib_is_caller() { 48 | local -i is_mode_direct=1 49 | 50 | # Handle options. 51 | while (( $# > 0 )); do 52 | case "$1" in 53 | -i|--indirect) is_mode_direct=0; shift ;; 54 | --) shift; break ;; 55 | *) break ;; 56 | esac 57 | done 58 | 59 | # Arguments. 60 | local -r func="$1" 61 | 62 | # Check call stack. 63 | if (( is_mode_direct )); then 64 | [[ $func == "${FUNCNAME[2]}" ]] && return 0 65 | else 66 | local -i depth 67 | for (( depth=2; depth<${#FUNCNAME[@]}; ++depth )); do 68 | [[ $func == "${FUNCNAME[$depth]}" ]] && return 0 69 | done 70 | fi 71 | 72 | return 1 73 | } 74 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-10-batslib_err.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_err() : displays ' { 6 | run batslib_err 'm1' 'm2' 7 | [ "$status" -eq 0 ] 8 | [ "$output" == 'm1 m2' ] 9 | } 10 | 11 | @test 'batslib_err(): reads from STDIN' { 12 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 13 | echo 'm1' 'm2' | batslib_err" 14 | [ "$status" -eq 0 ] 15 | [ "$output" == 'm1 m2' ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-11-batslib_count_lines.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_count_lines() : displays the number of lines in ' { 6 | run batslib_count_lines $'a\nb\nc\n' 7 | [ "$status" -eq 0 ] 8 | [ "$output" == '3' ] 9 | } 10 | 11 | @test 'batslib_count_lines() : counts the last line when it is not terminated by a newline' { 12 | run batslib_count_lines $'a\nb\nc' 13 | [ "$status" -eq 0 ] 14 | [ "$output" == '3' ] 15 | } 16 | 17 | @test 'batslib_count_lines() : counts empty lines' { 18 | run batslib_count_lines $'\n\n\n' 19 | [ "$status" -eq 0 ] 20 | [ "$output" == '3' ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-12-batslib_is_single_line.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_is_single_line() : returns 0 if all are single-line' { 6 | run batslib_is_single_line 'a' $'b\n' 'c' 7 | [ "$status" -eq 0 ] 8 | } 9 | 10 | @test 'batslib_is_single_line() : returns 1 if at least one of is longer than one line' { 11 | run batslib_is_single_line 'a' $'b\nb' 'c' 12 | [ "$status" -eq 1 ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_get_max_single_line_key_width() : displays the length of the longest key' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_get_max_single_line_key_width "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "$output" == '5' ] 12 | } 13 | 14 | @test 'batslib_get_max_single_line_key_width() : only considers keys with single-line values' { 15 | local -ar pairs=( 'k _1' 'v 1' 16 | 'k 2' 'v 2' 17 | 'k __3' $'v\n3' ) 18 | run batslib_get_max_single_line_key_width "${pairs[@]}" 19 | [ "$status" -eq 0 ] 20 | [ "$output" == '4' ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-14-batslib_print_kv_single.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_single() : displays in two-column format with wide key column' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2 ' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_single 5 "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '3' ] 12 | [ "${lines[0]}" == 'k _1 : v 1' ] 13 | [ "${lines[1]}" == 'k 2 : v 2' ] 14 | [ "${lines[2]}" == 'k __3 : v 3' ] 15 | } 16 | 17 | @test 'batslib_print_kv_single() : does not truncate keys when the column is too narrow' { 18 | local -ar pairs=( 'k _1' 'v 1' 19 | 'k 2' 'v 2' 20 | 'k __3' 'v 3' ) 21 | run batslib_print_kv_single 0 "${pairs[@]}" 22 | [ "$status" -eq 0 ] 23 | [ "${#lines[@]}" == '3' ] 24 | [ "${lines[0]}" == 'k _1 : v 1' ] 25 | [ "${lines[1]}" == 'k 2 : v 2' ] 26 | [ "${lines[2]}" == 'k __3 : v 3' ] 27 | } 28 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-15-batslib_print_kv_multi.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_multi() : displays in multi-line format' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2' $'v 2-1\nv 2-2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_multi "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '7' ] 12 | [ "${lines[0]}" == 'k _1 (1 lines):' ] 13 | [ "${lines[1]}" == 'v 1' ] 14 | [ "${lines[2]}" == 'k 2 (2 lines):' ] 15 | [ "${lines[3]}" == 'v 2-1' ] 16 | [ "${lines[4]}" == 'v 2-2' ] 17 | [ "${lines[5]}" == 'k __3 (1 lines):' ] 18 | [ "${lines[6]}" == 'v 3' ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_single_or_multi() : displays in two-column format if all values are one line long' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2 ' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_single_or_multi 5 "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '3' ] 12 | [ "${lines[0]}" == 'k _1 : v 1' ] 13 | [ "${lines[1]}" == 'k 2 : v 2' ] 14 | [ "${lines[2]}" == 'k __3 : v 3' ] 15 | } 16 | 17 | @test 'batslib_print_kv_single_or_multi() : displays in multi-line format if at least one value is longer than one line' { 18 | local -ar pairs=( 'k _1' 'v 1' 19 | 'k 2' $'v 2-1\nv 2-2' 20 | 'k __3' 'v 3' ) 21 | run batslib_print_kv_single_or_multi 5 "${pairs[@]}" 22 | [ "$status" -eq 0 ] 23 | [ "${#lines[@]}" == '7' ] 24 | [ "${lines[0]}" == 'k _1 (1 lines):' ] 25 | [ "${lines[1]}" == ' v 1' ] 26 | [ "${lines[2]}" == 'k 2 (2 lines):' ] 27 | [ "${lines[3]}" == ' v 2-1' ] 28 | [ "${lines[4]}" == ' v 2-2' ] 29 | [ "${lines[5]}" == 'k __3 (1 lines):' ] 30 | [ "${lines[6]}" == ' v 3' ] 31 | } 32 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-17-batslib_prefix.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_prefix() : prefixes each line of the input with ' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | printf 'a\nb\nc\n' | batslib_prefix '_'" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '_a' ] 11 | [ "${lines[1]}" == '_b' ] 12 | [ "${lines[2]}" == '_c' ] 13 | } 14 | 15 | @test 'batslib_prefix() : prefixes the last line when it is not terminated by a newline' { 16 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 17 | printf 'a\nb\nc' | batslib_prefix '_'" 18 | [ "$status" -eq 0 ] 19 | [ "${#lines[@]}" -eq 3 ] 20 | [ "${lines[0]}" == '_a' ] 21 | [ "${lines[1]}" == '_b' ] 22 | [ "${lines[2]}" == '_c' ] 23 | } 24 | 25 | @test 'batslib_prefix() : prefixes empty lines' { 26 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 27 | printf '\n\n\n' | batslib_prefix '_'" 28 | [ "$status" -eq 0 ] 29 | [ "${#lines[@]}" -eq 3 ] 30 | [ "${lines[0]}" == '_' ] 31 | [ "${lines[1]}" == '_' ] 32 | [ "${lines[2]}" == '_' ] 33 | } 34 | 35 | @test 'batslib_prefix(): default to two spaces' { 36 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 37 | printf 'a\nb\nc\n' | batslib_prefix" 38 | [ "$status" -eq 0 ] 39 | [ "${#lines[@]}" -eq 3 ] 40 | [ "${lines[0]}" == ' a' ] 41 | [ "${lines[1]}" == ' b' ] 42 | [ "${lines[2]}" == ' c' ] 43 | } 44 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-18-batslib_mark.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_mark() : marks the -th line of the input with ' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | printf ' a\n b\n c\n' | batslib_mark '>' 0" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '>a' ] 11 | [ "${lines[1]}" == ' b' ] 12 | [ "${lines[2]}" == ' c' ] 13 | } 14 | 15 | @test 'batslib_mark() : marks multiple lines when is in ascending order' { 16 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 17 | printf ' a\n b\n c\n' | batslib_mark '>' 1 2" 18 | [ "$status" -eq 0 ] 19 | [ "${#lines[@]}" -eq 3 ] 20 | [ "${lines[0]}" == ' a' ] 21 | [ "${lines[1]}" == '>b' ] 22 | [ "${lines[2]}" == '>c' ] 23 | } 24 | 25 | @test 'batslib_mark() : marks multiple lines when is in random order' { 26 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 27 | printf ' a\n b\n c\n d\n' | batslib_mark '>' 2 1 3" 28 | [ "$status" -eq 0 ] 29 | [ "${#lines[@]}" -eq 4 ] 30 | [ "${lines[0]}" == ' a' ] 31 | [ "${lines[1]}" == '>b' ] 32 | [ "${lines[2]}" == '>c' ] 33 | [ "${lines[3]}" == '>d' ] 34 | } 35 | 36 | @test 'batslib_mark() : ignores duplicate indices' { 37 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 38 | printf ' a\n b\n c\n' | batslib_mark '>' 1 2 1" 39 | [ "$status" -eq 0 ] 40 | [ "${#lines[@]}" -eq 3 ] 41 | [ "${lines[0]}" == ' a' ] 42 | [ "${lines[1]}" == '>b' ] 43 | [ "${lines[2]}" == '>c' ] 44 | } 45 | 46 | @test 'batslib_mark() : outputs the input untouched if is the empty string' { 47 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 48 | printf ' a\n b\n c\n' | batslib_mark '' 1" 49 | [ "$status" -eq 0 ] 50 | [ "${#lines[@]}" -eq 3 ] 51 | [ "${lines[0]}" == ' a' ] 52 | [ "${lines[1]}" == ' b' ] 53 | [ "${lines[2]}" == ' c' ] 54 | } 55 | 56 | @test 'batslib_mark() : marks the last line when it is not terminated by a newline' { 57 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 58 | printf ' a\n b\n c' | batslib_mark '>' 2" 59 | [ "$status" -eq 0 ] 60 | [ "${#lines[@]}" -eq 3 ] 61 | [ "${lines[0]}" == ' a' ] 62 | [ "${lines[1]}" == ' b' ] 63 | [ "${lines[2]}" == '>c' ] 64 | } 65 | 66 | @test 'batslib_mark() : does not truncate if it is longer than the marked line' { 67 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 68 | printf '\n' | batslib_mark '>' 0" 69 | [ "$status" -eq 0 ] 70 | [ "${#lines[@]}" -eq 1 ] 71 | [ "${lines[0]}" == '>' ] 72 | } 73 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/50-output-19-batslib_decorate.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_decorate() : encloses the input in a footer line and a header line containing <title>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | echo 'body' | batslib_decorate 'title'" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '-- title --' ] 11 | [ "${lines[1]}" == 'body' ] 12 | [ "${lines[2]}" == '--' ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/51-error-10-fail.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'fail() <message>: returns 1 and displays <message>' { 6 | run fail 'message' 7 | [ "$status" -eq 1 ] 8 | [ "$output" == 'message' ] 9 | } 10 | 11 | @test 'fail(): reads <message> from STDIN' { 12 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 13 | echo 'message' | fail" 14 | [ "$status" -eq 1 ] 15 | [ "$output" == 'message' ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/52-lang-10-batslib_is_caller.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load 'test_helper' 4 | 5 | 6 | # Test functions 7 | test_func_lvl_2() { 8 | test_func_lvl_1 "$@" 9 | } 10 | 11 | test_func_lvl_1() { 12 | test_func_lvl_0 "$@" 13 | } 14 | 15 | test_func_lvl_0() { 16 | batslib_is_caller "$@" 17 | } 18 | 19 | 20 | # 21 | # Direct invocation 22 | # 23 | 24 | # Interface 25 | @test 'batslib_is_caller() <function>: returns 0 if the current function was called directly from <function>' { 26 | run test_func_lvl_1 test_func_lvl_1 27 | [ "$status" -eq 0 ] 28 | [ "${#lines[@]}" -eq 0 ] 29 | } 30 | 31 | @test 'batslib_is_caller() <function>: returns 1 if the current function was not called directly from <function>' { 32 | run test_func_lvl_0 test_func_lvl_1 33 | [ "$status" -eq 1 ] 34 | [ "${#lines[@]}" -eq 0 ] 35 | } 36 | 37 | # Correctness 38 | @test 'batslib_is_caller() <function>: the current function does not appear on the call stack' { 39 | run test_func_lvl_0 test_func_lvl_0 40 | [ "$status" -eq 1 ] 41 | [ "${#lines[@]}" -eq 0 ] 42 | } 43 | 44 | 45 | # 46 | # Indirect invocation 47 | # 48 | 49 | # Options 50 | test_i_indirect() { 51 | run test_func_lvl_2 "$@" 52 | [ "$status" -eq 0 ] 53 | [ "${#lines[@]}" -eq 0 ] 54 | } 55 | 56 | @test 'batslib_is_caller() -i <function>: enables indirect checking' { 57 | test_i_indirect -i test_func_lvl_2 58 | } 59 | 60 | @test 'batslib_is_caller() --indirect <function>: enables indirect checking' { 61 | test_i_indirect --indirect test_func_lvl_2 62 | } 63 | 64 | # Interface 65 | @test 'batslib_is_caller() --indirect <function>: returns 0 if the current function was called indirectly from <function>' { 66 | run test_func_lvl_2 --indirect test_func_lvl_2 67 | [ "$status" -eq 0 ] 68 | [ "${#lines[@]}" -eq 0 ] 69 | } 70 | 71 | @test 'batslib_is_caller() --indirect <function>: returns 1 if the current function was not called indirectly from <function>' { 72 | run test_func_lvl_1 --indirect test_func_lvl_2 73 | [ "$status" -eq 1 ] 74 | [ "${#lines[@]}" -eq 0 ] 75 | } 76 | 77 | # Correctness 78 | @test 'batslib_is_caller() --indirect <function>: direct invocation is a special case of indirect invocation with zero intermediate calls' { 79 | run test_func_lvl_1 --indirect test_func_lvl_1 80 | [ "$status" -eq 0 ] 81 | [ "${#lines[@]}" -eq 0 ] 82 | } 83 | 84 | @test 'batslib_is_caller() --indirect <function>: the current function does not appear on the call stack' { 85 | run test_func_lvl_0 --indirect test_func_lvl_0 86 | [ "$status" -eq 1 ] 87 | [ "${#lines[@]}" -eq 0 ] 88 | } 89 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats-support/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." 3 | 4 | # Load library. 5 | load '../load' 6 | } 7 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sh eol=lf 3 | libexec/* eol=lf 4 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | script: bin/bats --tap test 3 | notifications: 4 | email: 5 | on_success: never 6 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Sam Stephenson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/bin/bats: -------------------------------------------------------------------------------- 1 | ../libexec/bats -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | resolve_link() { 5 | $(type -p greadlink readlink | head -1) "$1" 6 | } 7 | 8 | abs_dirname() { 9 | local cwd="$(pwd)" 10 | local path="$1" 11 | 12 | while [ -n "$path" ]; do 13 | cd "${path%/*}" 14 | local name="${path##*/}" 15 | path="$(resolve_link "$name" || true)" 16 | done 17 | 18 | pwd 19 | cd "$cwd" 20 | } 21 | 22 | PREFIX="$1" 23 | if [ -z "$1" ]; then 24 | { echo "usage: $0 <prefix>" 25 | echo " e.g. $0 /usr/local" 26 | } >&2 27 | exit 1 28 | fi 29 | 30 | BATS_ROOT="$(abs_dirname "$0")" 31 | mkdir -p "$PREFIX"/{bin,libexec,share/man/man{1,7}} 32 | cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin 33 | cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec 34 | cp "$BATS_ROOT"/man/bats.1 "$PREFIX"/share/man/man1 35 | cp "$BATS_ROOT"/man/bats.7 "$PREFIX"/share/man/man7 36 | 37 | echo "Installed Bats to $PREFIX/bin/bats" 38 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/libexec/bats-exec-suite: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | count_only_flag="" 5 | if [ "$1" = "-c" ]; then 6 | count_only_flag=1 7 | shift 8 | fi 9 | 10 | extended_syntax_flag="" 11 | if [ "$1" = "-x" ]; then 12 | extended_syntax_flag="-x" 13 | shift 14 | fi 15 | 16 | trap "kill 0; exit 1" int 17 | 18 | count=0 19 | for filename in "$@"; do 20 | let count+="$(bats-exec-test -c "$filename")" 21 | done 22 | 23 | if [ -n "$count_only_flag" ]; then 24 | echo "$count" 25 | exit 26 | fi 27 | 28 | echo "1..$count" 29 | status=0 30 | offset=0 31 | for filename in "$@"; do 32 | index=0 33 | { 34 | IFS= read -r # 1..n 35 | while IFS= read -r line; do 36 | case "$line" in 37 | "begin "* ) 38 | let index+=1 39 | echo "${line/ $index / $(($offset + $index)) }" 40 | ;; 41 | "ok "* | "not ok "* ) 42 | [ -n "$extended_syntax_flag" ] || let index+=1 43 | echo "${line/ $index / $(($offset + $index)) }" 44 | [ "${line:0:6}" != "not ok" ] || status=1 45 | ;; 46 | * ) 47 | echo "$line" 48 | ;; 49 | esac 50 | done 51 | } < <( bats-exec-test $extended_syntax_flag "$filename" ) 52 | offset=$(($offset + $index)) 53 | done 54 | 55 | exit "$status" 56 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/libexec/bats-preprocess: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | encode_name() { 5 | local name="$1" 6 | local result="test_" 7 | 8 | if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then 9 | name="${name//_/-5f}" 10 | name="${name//-/-2d}" 11 | name="${name// /_}" 12 | result+="$name" 13 | else 14 | local length="${#name}" 15 | local char i 16 | 17 | for ((i=0; i<length; i++)); do 18 | char="${name:$i:1}" 19 | if [ "$char" = " " ]; then 20 | result+="_" 21 | elif [[ "$char" =~ [[:alnum:]] ]]; then 22 | result+="$char" 23 | else 24 | result+="$(printf -- "-%02x" \'"$char")" 25 | fi 26 | done 27 | fi 28 | 29 | echo "$result" 30 | } 31 | 32 | tests=() 33 | index=0 34 | pattern='^ *@test *([^ ].*) *\{ *(.*)$' 35 | 36 | while IFS= read -r line; do 37 | let index+=1 38 | if [[ "$line" =~ $pattern ]]; then 39 | quoted_name="${BASH_REMATCH[1]}" 40 | body="${BASH_REMATCH[2]}" 41 | name="$(eval echo "$quoted_name")" 42 | encoded_name="$(encode_name "$name")" 43 | tests["${#tests[@]}"]="$encoded_name" 44 | echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}" 45 | else 46 | printf "%s\n" "$line" 47 | fi 48 | done 49 | 50 | for test_name in "${tests[@]}"; do 51 | echo "bats_test_function ${test_name}" 52 | done 53 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/man/Makefile: -------------------------------------------------------------------------------- 1 | RONN := ronn 2 | PAGES := bats.1 bats.7 3 | 4 | all: $(PAGES) 5 | 6 | bats.1: bats.1.ronn 7 | $(RONN) -r $< 8 | 9 | bats.7: bats.7.ronn 10 | $(RONN) -r $< 11 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/man/README.md: -------------------------------------------------------------------------------- 1 | Bats man pages are generated with [Ronn](http://rtomayko.github.io/ronn/). 2 | 3 | After making changes to `bats.1.ronn` or `bats.7.ronn`, run `make` in 4 | this directory to generate `bats.1` and `bats.7`. **Do not edit the 5 | `bats.1` or `bats.7` files directly.** 6 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/man/bats.1.ronn: -------------------------------------------------------------------------------- 1 | bats(1) -- Bash Automated Testing System 2 | ======================================== 3 | 4 | 5 | SYNOPSIS 6 | -------- 7 | 8 | bats [-c] [-p | -t] <test> [<test> ...] 9 | 10 | <test> is the path to a Bats test file, or the path to a directory 11 | containing Bats test files. 12 | 13 | 14 | DESCRIPTION 15 | ----------- 16 | 17 | Bats is a TAP-compliant testing framework for Bash. It provides a simple 18 | way to verify that the UNIX programs you write behave as expected. 19 | 20 | A Bats test file is a Bash script with special syntax for defining 21 | test cases. Under the hood, each test case is just a function with a 22 | description. 23 | 24 | Test cases consist of standard shell commands. Bats makes use of 25 | Bash's `errexit` (`set -e`) option when running test cases. If every 26 | command in the test case exits with a `0` status code (success), the 27 | test passes. In this way, each line is an assertion of truth. 28 | 29 | See `bats`(7) for more information on writing Bats tests. 30 | 31 | 32 | RUNNING TESTS 33 | ------------- 34 | 35 | To run your tests, invoke the `bats` interpreter with a path to a test 36 | file. The file's test cases are run sequentially and in isolation. If 37 | all the test cases pass, `bats` exits with a `0` status code. If there 38 | are any failures, `bats` exits with a `1` status code. 39 | 40 | You can invoke the `bats` interpreter with multiple test file arguments, 41 | or with a path to a directory containing multiple `.bats` files. Bats 42 | will run each test file individually and aggregate the results. If any 43 | test case fails, `bats` exits with a `1` status code. 44 | 45 | 46 | OPTIONS 47 | ------- 48 | 49 | * `-c`, `--count`: 50 | Count the number of test cases without running any tests 51 | * `-h`, `--help`: 52 | Display help message 53 | * `-p`, `--pretty`: 54 | Show results in pretty format (default for terminals) 55 | * `-t`, `--tap`: 56 | Show results in TAP format 57 | * `-v`, `--version`: 58 | Display the version number 59 | 60 | 61 | OUTPUT 62 | ------ 63 | 64 | When you run Bats from a terminal, you'll see output as each test is 65 | performed, with a check-mark next to the test's name if it passes or 66 | an "X" if it fails. 67 | 68 | $ bats addition.bats 69 | ✓ addition using bc 70 | ✓ addition using dc 71 | 72 | 2 tests, 0 failures 73 | 74 | If Bats is not connected to a terminal--in other words, if you run it 75 | from a continuous integration system or redirect its output to a 76 | file--the results are displayed in human-readable, machine-parsable 77 | TAP format. You can force TAP output from a terminal by invoking Bats 78 | with the `--tap` option. 79 | 80 | $ bats --tap addition.bats 81 | 1..2 82 | ok 1 addition using bc 83 | ok 2 addition using dc 84 | 85 | 86 | EXIT STATUS 87 | ----------- 88 | 89 | The `bats` interpreter exits with a value of `0` if all test cases pass, 90 | or `1` if one or more test cases fail. 91 | 92 | 93 | SEE ALSO 94 | -------- 95 | 96 | Bats wiki: _https://github.com/sstephenson/bats/wiki/_ 97 | 98 | `bash`(1), `bats`(7) 99 | 100 | 101 | COPYRIGHT 102 | --------- 103 | 104 | (c) 2014 Sam Stephenson 105 | 106 | Bats is released under the terms of an MIT-style license. 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats", 3 | "version": "v0.4.0", 4 | "description": "Bash Automated Testing System", 5 | "install": "./install.sh ${PREFIX:-/usr/local}", 6 | "scripts": [ "libexec/bats", "libexec/bats-exec-suite", "libexec/bats-exec-test", "libexec/bats-format-tap-stream", "libexec/bats-preprocess", "bin/bats" ] 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/dos_line.bats: -------------------------------------------------------------------------------- 1 | @test "foo" { 2 | echo "foo" 3 | } 4 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/empty.bats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/empty.bats -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/environment.bats: -------------------------------------------------------------------------------- 1 | @test "setting a variable" { 2 | variable=1 3 | [ $variable -eq 1 ] 4 | } 5 | 6 | @test "variables do not persist across tests" { 7 | [ -z "$variable" ] 8 | } 9 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/failing.bats: -------------------------------------------------------------------------------- 1 | @test "a failing test" { 2 | true 3 | true 4 | eval "( exit ${STATUS:-1} )" 5 | } 6 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/failing_and_passing.bats: -------------------------------------------------------------------------------- 1 | @test "a failing test" { 2 | false 3 | } 4 | 5 | @test "a passing test" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/failing_helper.bats: -------------------------------------------------------------------------------- 1 | load "test_helper" 2 | 3 | @test "failing helper function" { 4 | true 5 | failing_helper 6 | } 7 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/failing_setup.bats: -------------------------------------------------------------------------------- 1 | setup() { 2 | false 3 | } 4 | 5 | @test "truth" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/failing_teardown.bats: -------------------------------------------------------------------------------- 1 | teardown() { 2 | eval "( exit ${STATUS:-1} )" 3 | } 4 | 5 | @test "truth" { 6 | [ "$PASS" = "1" ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/intact.bats: -------------------------------------------------------------------------------- 1 | @test "dash-e on beginning of line" { 2 | run cat - <<INPUT 3 | -e 4 | INPUT 5 | test "$output" = "-e" 6 | } 7 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/invalid_tap.bats: -------------------------------------------------------------------------------- 1 | echo "This isn't TAP!" 2 | echo "Good day to you" 3 | exit 1 4 | 5 | @test "truth" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/load.bats: -------------------------------------------------------------------------------- 1 | [ -n "$HELPER_NAME" ] || HELPER_NAME="test_helper" 2 | load "$HELPER_NAME" 3 | 4 | @test "calling a loaded helper" { 5 | help_me 6 | } 7 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/loop_keep_IFS.bats: -------------------------------------------------------------------------------- 1 | # see issue #89 2 | loop_func() { 3 | local search="none one two tree" 4 | local d 5 | 6 | for d in $search ; do 7 | echo $d 8 | done 9 | } 10 | 11 | @test "loop_func" { 12 | run loop_func 13 | [[ "${lines[3]}" == 'tree' ]] 14 | run loop_func 15 | [[ "${lines[2]}" == 'two' ]] 16 | } 17 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/output.bats: -------------------------------------------------------------------------------- 1 | @test "success writing to stdout" { 2 | echo "success stdout 1" 3 | echo "success stdout 2" 4 | } 5 | 6 | @test "success writing to stderr" { 7 | echo "success stderr" >&2 8 | } 9 | 10 | @test "failure writing to stdout" { 11 | echo "failure stdout 1" 12 | echo "failure stdout 2" 13 | false 14 | } 15 | 16 | @test "failure writing to stderr" { 17 | echo "failure stderr" >&2 18 | false 19 | } 20 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/passing.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/passing_and_failing.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a failing test" { 6 | false 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/passing_and_skipping.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a skipping test" { 6 | skip 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/passing_failing_and_skipping.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a skipping test" { 6 | skip 7 | } 8 | 9 | @test "a failing test" { 10 | false 11 | } 12 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/setup.bats: -------------------------------------------------------------------------------- 1 | LOG="$TMP/setup.log" 2 | 3 | setup() { 4 | echo "$BATS_TEST_NAME" >> "$LOG" 5 | } 6 | 7 | @test "one" { 8 | [ "$(tail -n 1 "$LOG")" = "test_one" ] 9 | } 10 | 11 | @test "two" { 12 | [ "$(tail -n 1 "$LOG")" = "test_two" ] 13 | } 14 | 15 | @test "three" { 16 | [ "$(tail -n 1 "$LOG")" = "test_three" ] 17 | } 18 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/single_line.bats: -------------------------------------------------------------------------------- 1 | @test "empty" { } 2 | 3 | @test "passing" { true; } 4 | 5 | @test "input redirection" { diff - <( echo hello ); } <<EOS 6 | hello 7 | EOS 8 | 9 | @test "failing" { false; } 10 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/skipped.bats: -------------------------------------------------------------------------------- 1 | @test "a skipped test" { 2 | skip 3 | } 4 | 5 | @test "a skipped test with a reason" { 6 | skip "a reason" 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/teardown.bats: -------------------------------------------------------------------------------- 1 | LOG="$TMP/teardown.log" 2 | 3 | teardown() { 4 | echo "$BATS_TEST_NAME" >> "$LOG" 5 | } 6 | 7 | @test "one" { 8 | true 9 | } 10 | 11 | @test "two" { 12 | false 13 | } 14 | 15 | @test "three" { 16 | true 17 | } 18 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/test_helper.bash: -------------------------------------------------------------------------------- 1 | help_me() { 2 | true 3 | } 4 | 5 | failing_helper() { 6 | false 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/bats/without_trailing_newline.bats: -------------------------------------------------------------------------------- 1 | @test "truth" { 2 | true 3 | } -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/suite/empty/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/tests/devtools/mcd-cli/test/libs/bats/test/fixtures/suite/empty/.gitkeep -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/suite/multiple/a.bats: -------------------------------------------------------------------------------- 1 | @test "truth" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/suite/multiple/b.bats: -------------------------------------------------------------------------------- 1 | @test "more truth" { 2 | true 3 | } 4 | 5 | @test "quasi-truth" { 6 | [ -z "$FLUNK" ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/fixtures/suite/single/test.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/suite.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | fixtures suite 5 | 6 | @test "running a suite with no test files" { 7 | run bats "$FIXTURE_ROOT/empty" 8 | [ $status -eq 0 ] 9 | [ "$output" = "1..0" ] 10 | } 11 | 12 | @test "running a suite with one test file" { 13 | run bats "$FIXTURE_ROOT/single" 14 | [ $status -eq 0 ] 15 | [ "${lines[0]}" = "1..1" ] 16 | [ "${lines[1]}" = "ok 1 a passing test" ] 17 | } 18 | 19 | @test "counting tests in a suite" { 20 | run bats -c "$FIXTURE_ROOT/single" 21 | [ $status -eq 0 ] 22 | [ "$output" -eq 1 ] 23 | 24 | run bats -c "$FIXTURE_ROOT/multiple" 25 | [ $status -eq 0 ] 26 | [ "$output" -eq 3 ] 27 | } 28 | 29 | @test "aggregated output of multiple tests in a suite" { 30 | run bats "$FIXTURE_ROOT/multiple" 31 | [ $status -eq 0 ] 32 | [ "${lines[0]}" = "1..3" ] 33 | echo "$output" | grep "^ok . truth" 34 | echo "$output" | grep "^ok . more truth" 35 | echo "$output" | grep "^ok . quasi-truth" 36 | } 37 | 38 | @test "a failing test in a suite results in an error exit code" { 39 | FLUNK=1 run bats "$FIXTURE_ROOT/multiple" 40 | [ $status -eq 1 ] 41 | [ "${lines[0]}" = "1..3" ] 42 | echo "$output" | grep "^not ok . quasi-truth" 43 | } 44 | 45 | @test "running an ad-hoc suite by specifying multiple test files" { 46 | run bats "$FIXTURE_ROOT/multiple/a.bats" "$FIXTURE_ROOT/multiple/b.bats" 47 | [ $status -eq 0 ] 48 | [ "${lines[0]}" = "1..3" ] 49 | echo "$output" | grep "^ok . truth" 50 | echo "$output" | grep "^ok . more truth" 51 | echo "$output" | grep "^ok . quasi-truth" 52 | } 53 | 54 | @test "extended syntax in suite" { 55 | FLUNK=1 run bats-exec-suite -x "$FIXTURE_ROOT/multiple/"*.bats 56 | [ $status -eq 1 ] 57 | [ "${lines[0]}" = "1..3" ] 58 | [ "${lines[1]}" = "begin 1 truth" ] 59 | [ "${lines[2]}" = "ok 1 truth" ] 60 | [ "${lines[3]}" = "begin 2 more truth" ] 61 | [ "${lines[4]}" = "ok 2 more truth" ] 62 | [ "${lines[5]}" = "begin 3 quasi-truth" ] 63 | [ "${lines[6]}" = "not ok 3 quasi-truth" ] 64 | } 65 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/libs/bats/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | fixtures() { 2 | FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1" 3 | RELATIVE_FIXTURE_ROOT="$(bats_trim_filename "$FIXTURE_ROOT")" 4 | } 5 | 6 | setup() { 7 | export TMP="$BATS_TEST_DIRNAME/tmp" 8 | } 9 | 10 | filter_control_sequences() { 11 | "$@" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' 12 | } 13 | 14 | teardown() { 15 | [ -d "$TMP" ] && rm -f "$TMP"/* 16 | } 17 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/test.bats: -------------------------------------------------------------------------------- 1 | #!./test/libs/bats/bin/bats 2 | 3 | load 'libs/bats-support/load' 4 | load 'libs/bats-assert/load' 5 | 6 | 7 | . test_helper.bash 8 | 9 | @test "mcd ilks" { 10 | run mcd ilks 11 | assert_line 'ILK GEM DESC' 12 | } 13 | 14 | @test "mcd --ilk=REP-A gem join 50" { 15 | run mcd --ilk=REP-A gem join 50 16 | assert_line --index 5 'vat 50.000000000000000000 Unlocked collateral (REP)' 17 | } 18 | 19 | @test "mcd --ilk=REP-A frob 50 1" { 20 | run mcd --ilk=REP-A frob 50 1 21 | assert_line --index 5 'ilk REP-A Collateral type' 22 | } 23 | 24 | @test "mcd dai exit 1" { 25 | run mcd dai exit 1 26 | assert_line --index 6 'ext 1.000000000000000000 ERC20 Dai balance' 27 | } 28 | 29 | @test "mcd dai join 1" { 30 | run mcd dai join 1 31 | assert_line --index 6 'ext 0.000000000000000000 ERC20 Dai balance' 32 | } 33 | 34 | @test "mcd --ilk=REP-A frob -- -50 -1" { 35 | run mcd --ilk=REP-A frob -- -50 -1 36 | assert_line --index 5 'ilk REP-A Collateral type' 37 | } 38 | 39 | @test "mcd --ilk=REP-A gem exit 50" { 40 | run mcd --ilk=REP-A gem exit 50 41 | assert_line --index 5 'vat 0.000000000000000000 Unlocked collateral (REP)' 42 | } 43 | -------------------------------------------------------------------------------- /tests/devtools/mcd-cli/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export MCD_CHAIN=kovan 3 | export SETH_CHAIN=kovan 4 | export ETH_FROM=0x18d92ba0b79d769e6b781b92ee2e9d45b3e1e017 5 | export ETH_KEYSTORE=./account/ 6 | export ETH_PASSWORD=./account/pass -------------------------------------------------------------------------------- /tests/devtools/test-chain-guide/cdp.js: -------------------------------------------------------------------------------- 1 | const Maker = require('@makerdao/dai'); 2 | const McdPlugin = require('@makerdao/dai-plugin-mcd').default; 3 | const ETH = require('@makerdao/dai-plugin-mcd').ETH; 4 | const MDAI = require('@makerdao/dai-plugin-mcd').MDAI; 5 | 6 | async function start() { 7 | try { 8 | const maker = await Maker.create('test', { 9 | plugins: [ 10 | [McdPlugin, {}] 11 | ] 12 | }); 13 | await maker.authenticate(); 14 | 15 | const balance = await maker 16 | .service('token') 17 | .getToken('ETH') 18 | .balance(); 19 | console.log('Account: ', maker.currentAddress()); 20 | console.log('Balance', balance.toString()); 21 | 22 | const cdp = await maker 23 | .service('mcd:cdpManager') 24 | .openLockAndDraw('ETH-A', ETH(1), MDAI(20)); 25 | 26 | console.log('Opened CDP #'+cdp.id); 27 | console.log('Collateral amount:'+cdp.collateralAmount.toString()); 28 | console.log('Debt Value:'+cdp.debtValue.toString()); 29 | 30 | return(cdp.debtValue.toString()); 31 | } catch (error) { 32 | console.log('error', error); 33 | } 34 | } 35 | module.exports = start; 36 | -------------------------------------------------------------------------------- /tests/devtools/test-chain-guide/cdp.test.js: -------------------------------------------------------------------------------- 1 | const start = require('./cdp'); 2 | 3 | // Before running the test, make sure to run the testchain instance 4 | // from the test-chain-guide 5 | 6 | test('check to see if 20 dai is generated', async () => { 7 | expect(await start()).toMatch("20.00 MDAI"); 8 | }); 9 | -------------------------------------------------------------------------------- /tests/devtools/test-chain-guide/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-chain-guide", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest", 8 | "start": "node cdp.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "@makerdao/dai": "^0.23.0-rc.5", 15 | "@makerdao/dai-plugin-mcd": "^1.0.5" 16 | }, 17 | "devDependencies": { 18 | "jest": "^24.9.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/devtools/test-chain-guide/test-chain-guide.md: -------------------------------------------------------------------------------- 1 | # Test-chain-guide Test 2 | 3 | This tests the JS code in the [test-chain-guide](https://github.com/makerdao/developerguides/blob/master/devtools/test-chain-guide/test-chain-guide.md). 4 | 5 | ## Steps 6 | 7 | 0 - Navigate to test-chain guide folder 8 | 1 - Run `npm install` to get necessary dependencies. 9 | 3 - Run `testchain` instance 10 | 2 - Run `npm test` to run the tests. 11 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/mcd-seth-cdp-manager.MD: -------------------------------------------------------------------------------- 1 | # MCD-SETH CDP MANAGER TEST 2 | 3 | *Version: [0.2.11](https://changelog.makerdao.com/releases/0.2.11/index.html) kovan deployment* 4 | 5 | This test checks the [CDP Manager Guide](https://github.com/makerdao/developerguides/blob/master/mcd/mcd-seth/mcd-seth-cdp-manager.md) against the 0.2.11 mcd realease to see if there's any breaking changes. 6 | The `test` folder has necessary files to run the test. 7 | 8 | Make sure to install the [seth](https://github.com/makerdao/developerguides/blob/master/devtools/seth/seth-guide-01/seth-guide-01.md) tool first before running the test. 9 | 10 | ## Install 11 | 12 | - Linux: `sudo apt install bats` 13 | - Mac: 14 | - Press Command+Space and type Terminal and press enter/return key. 15 | - Run in Terminal app: 16 | `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null` 17 | and press enter/return key. 18 | If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish. 19 | - Run: `brew install bats` 20 | 21 | ## Steps 22 | 23 | - Navigate to `test` folder 24 | - To run the tests, run `bats test.bats` command and the test will start. 25 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/account/mcd-cli-test-keystore: -------------------------------------------------------------------------------- 1 | {"version":3,"id":"93dd8afb-9925-4622-ae37-4c70d642bb08","address":"18d92ba0b79d769e6b781b92ee2e9d45b3e1e017","crypto":{"ciphertext":"cb90ef46af693ed78da0741f9c03164a8b6773e6db207f9d35624b7e026bc720","cipherparams":{"iv":"2baf3504d167e0c0eeffb499e4b717f6"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"57f47ef42d6ef6f04f7309decf7e7819ff582ed228bcffe9be7ce537c384c9b5","n":8192,"r":8,"p":1},"mac":"ae38a6d51d1bad1230e0ec6de69c6d911810c24d4412d3e2d8560b185a24b799"}} -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/account/pass: -------------------------------------------------------------------------------- 1 | mcd-cli-test 2 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_install: 3 | - ./script/install-bats.sh 4 | - git clone --depth 1 https://github.com/ztombol/bats-support ../bats-support 5 | before_script: 6 | - export PATH="${HOME}/.local/bin:${PATH}" 7 | script: 8 | - bats test 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 7 | ## [0.3.0] - 2016-03-22 8 | 9 | ### Removed 10 | 11 | - Move `fail()` to `bats-support` 12 | 13 | 14 | ## [0.2.0] - 2016-03-11 15 | 16 | ### Added 17 | 18 | - `refute()` to complement `assert()` 19 | - `npm` support 20 | 21 | ### Fixed 22 | 23 | - Not consuming the `--` when stopping option parsing in 24 | `assert_output`, `refute_output`, `assert_line` and `refute_line` 25 | 26 | 27 | ## 0.1.0 - 2016-02-16 28 | 29 | ### Added 30 | 31 | - Reporting arbitrary failures with `fail()` 32 | - Generic assertions with `assert()` and `assert_equal()` 33 | - Testing exit status with `assert_success()` and `assert_failure()` 34 | - Testing output with `assert_output()` and `refute_output()` 35 | - Testing individual lines with `assert_line()` and `refute_line()` 36 | 37 | 38 | [0.3.0]: https://github.com/ztombol/bats-assert/compare/v0.2.0...v0.3.0 39 | [0.2.0]: https://github.com/ztombol/bats-assert/compare/v0.1.0...v0.2.0 40 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash" 2 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats-assert", 3 | "version": "0.3.0", 4 | "private": true, 5 | "peerDependencies": { 6 | "bats-support": "git+https://github.com/ztombol/bats-support.git#v0.2.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/script/install-bats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o xtrace 4 | 5 | git clone --depth 1 https://github.com/sstephenson/bats 6 | cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/test/50-assert-11-assert.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'assert() <expression>: returns 0 if <expression> evaluates to TRUE' { 6 | run assert true 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'assert() <expression>: returns 1 and displays <expression> if it evaluates to FALSE' { 12 | run assert false 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 3 ] 15 | [ "${lines[0]}" == '-- assertion failed --' ] 16 | [ "${lines[1]}" == 'expression : false' ] 17 | [ "${lines[2]}" == '--' ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/test/50-assert-12-assert_equal.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'assert_equal() <actual> <expected>: returns 0 if <actual> equals <expected>' { 6 | run assert_equal 'a' 'a' 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'assert_equal() <actual> <expected>: returns 1 and displays details if <actual> does not equal <expected>' { 12 | run assert_equal 'a' 'b' 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 4 ] 15 | [ "${lines[0]}" == '-- values do not equal --' ] 16 | [ "${lines[1]}" == 'expected : b' ] 17 | [ "${lines[2]}" == 'actual : a' ] 18 | [ "${lines[3]}" == '--' ] 19 | } 20 | 21 | @test 'assert_equal() <actual> <expected>: displays details in multi-line format if <actual> is longer than one line' { 22 | run assert_equal $'a 0\na 1' 'b' 23 | [ "$status" -eq 1 ] 24 | [ "${#lines[@]}" -eq 7 ] 25 | [ "${lines[0]}" == '-- values do not equal --' ] 26 | [ "${lines[1]}" == 'expected (1 lines):' ] 27 | [ "${lines[2]}" == ' b' ] 28 | [ "${lines[3]}" == 'actual (2 lines):' ] 29 | [ "${lines[4]}" == ' a 0' ] 30 | [ "${lines[5]}" == ' a 1' ] 31 | [ "${lines[6]}" == '--' ] 32 | } 33 | 34 | @test 'assert_equal() <actual> <expected>: displays details in multi-line format if <expected> is longer than one line' { 35 | run assert_equal 'a' $'b 0\nb 1' 36 | [ "$status" -eq 1 ] 37 | [ "${#lines[@]}" -eq 7 ] 38 | [ "${lines[0]}" == '-- values do not equal --' ] 39 | [ "${lines[1]}" == 'expected (2 lines):' ] 40 | [ "${lines[2]}" == ' b 0' ] 41 | [ "${lines[3]}" == ' b 1' ] 42 | [ "${lines[4]}" == 'actual (1 lines):' ] 43 | [ "${lines[5]}" == ' a' ] 44 | [ "${lines[6]}" == '--' ] 45 | } 46 | 47 | @test 'assert_equal() <actual> <expected>: performs literal matching' { 48 | run assert_equal 'a' '*' 49 | [ "$status" -eq 1 ] 50 | } 51 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/test/50-assert-13-assert_success.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test "assert_success(): returns 0 if \`\$status' is 0" { 6 | run true 7 | run assert_success 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 0 ] 10 | } 11 | 12 | @test "assert_success(): returns 1 and displays details if \`\$status' is not 0" { 13 | run bash -c 'echo "a" 14 | exit 1' 15 | run assert_success 16 | [ "$status" -eq 1 ] 17 | [ "${#lines[@]}" -eq 4 ] 18 | [ "${lines[0]}" == '-- command failed --' ] 19 | [ "${lines[1]}" == 'status : 1' ] 20 | [ "${lines[2]}" == 'output : a' ] 21 | [ "${lines[3]}" == '--' ] 22 | } 23 | 24 | @test "assert_success(): displays \`\$output' in multi-line format if it is longer than one line" { 25 | run bash -c 'printf "a 0\na 1" 26 | exit 1' 27 | run assert_success 28 | [ "$status" -eq 1 ] 29 | [ "${#lines[@]}" -eq 6 ] 30 | [ "${lines[0]}" == '-- command failed --' ] 31 | [ "${lines[1]}" == 'status : 1' ] 32 | [ "${lines[2]}" == 'output (2 lines):' ] 33 | [ "${lines[3]}" == ' a 0' ] 34 | [ "${lines[4]}" == ' a 1' ] 35 | [ "${lines[5]}" == '--' ] 36 | } 37 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/test/50-assert-14-assert_failure.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test "assert_failure(): returns 0 if \`\$status' is not 0" { 6 | run false 7 | run assert_failure 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 0 ] 10 | } 11 | 12 | @test "assert_failure(): returns 1 and displays details if \`\$status' is 0" { 13 | run bash -c 'echo "a" 14 | exit 0' 15 | run assert_failure 16 | [ "$status" -eq 1 ] 17 | [ "${#lines[@]}" -eq 3 ] 18 | [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] 19 | [ "${lines[1]}" == 'output : a' ] 20 | [ "${lines[2]}" == '--' ] 21 | } 22 | 23 | @test "assert_failure(): displays \`\$output' in multi-line format if it is longer then one line" { 24 | run bash -c 'printf "a 0\na 1" 25 | exit 0' 26 | run assert_failure 27 | [ "$status" -eq 1 ] 28 | [ "${#lines[@]}" -eq 5 ] 29 | [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] 30 | [ "${lines[1]}" == 'output (2 lines):' ] 31 | [ "${lines[2]}" == ' a 0' ] 32 | [ "${lines[3]}" == ' a 1' ] 33 | [ "${lines[4]}" == '--' ] 34 | } 35 | 36 | @test "assert_failure() <status>: returns 0 if \`\$status' equals <status>" { 37 | run bash -c 'exit 1' 38 | run assert_failure 1 39 | [ "$status" -eq 0 ] 40 | [ "${#lines[@]}" -eq 0 ] 41 | } 42 | 43 | @test "assert_failure() <status>: returns 1 and displays details if \`\$status' does not equal <status>" { 44 | run bash -c 'echo "a" 45 | exit 1' 46 | run assert_failure 2 47 | [ "$status" -eq 1 ] 48 | [ "${#lines[@]}" -eq 5 ] 49 | [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] 50 | [ "${lines[1]}" == 'expected : 2' ] 51 | [ "${lines[2]}" == 'actual : 1' ] 52 | [ "${lines[3]}" == 'output : a' ] 53 | [ "${lines[4]}" == '--' ] 54 | } 55 | 56 | @test "assert_failure() <status>: displays \`\$output' in multi-line format if it is longer then one line" { 57 | run bash -c 'printf "a 0\na 1" 58 | exit 1' 59 | run assert_failure 2 60 | [ "$status" -eq 1 ] 61 | [ "${#lines[@]}" -eq 7 ] 62 | [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] 63 | [ "${lines[1]}" == 'expected : 2' ] 64 | [ "${lines[2]}" == 'actual : 1' ] 65 | [ "${lines[3]}" == 'output (2 lines):' ] 66 | [ "${lines[4]}" == ' a 0' ] 67 | [ "${lines[5]}" == ' a 1' ] 68 | [ "${lines[6]}" == '--' ] 69 | } 70 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/test/50-assert-19-refute.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'refute() <expression>: returns 0 if <expression> evaluates to FALSE' { 6 | run refute false 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'refute() <expression>: returns 1 and displays <expression> if it evaluates to TRUE' { 12 | run refute true 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 3 ] 15 | [ "${lines[0]}" == '-- assertion succeeded, but it was expected to fail --' ] 16 | [ "${lines[1]}" == 'expression : true' ] 17 | [ "${lines[2]}" == '--' ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-assert/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." 3 | export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}" 4 | 5 | # Load dependencies. 6 | load "${TEST_DEPS_DIR}/bats-support/load.bash" 7 | 8 | # Load library. 9 | load '../load' 10 | } 11 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_install: 3 | - ./script/install-bats.sh 4 | before_script: 5 | - export PATH="${HOME}/.local/bin:${PATH}" 6 | script: 7 | - bats test 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 7 | ## [0.3.0] - 2016-11-29 8 | 9 | ### Added 10 | 11 | - Restricting invocation to specific locations with 12 | `batslib_is_caller()` 13 | 14 | 15 | ## [0.2.0] - 2016-03-22 16 | 17 | ### Added 18 | 19 | - `npm` support 20 | - Reporting arbitrary failures with `fail()` (moved from `bats-assert`) 21 | 22 | ### Changed 23 | 24 | - Library renamed to `bats-support` 25 | 26 | 27 | ## 0.1.0 - 2016-02-16 28 | 29 | ### Added 30 | 31 | - Two-column key-value formatting with `batslib_print_kv_single()` 32 | - Multi-line key-value formatting with `batslib_print_kv_multi()` 33 | - Mixed formatting with `batslib_print_kv_single_or_multi()` 34 | - Header and footer decoration with `batslib_decorate()` 35 | - Prefixing lines with `batslib_prefix()` 36 | - Marking lines with `batslib_mark()` 37 | - Common output function `batslib_err()` 38 | - Line counting with `batslib_count_lines()` 39 | - Checking whether a text is one line long with 40 | `batslib_is_single_line()` 41 | - Determining key width for two-column and mixed formatting with 42 | `batslib_get_max_single_line_key_width()` 43 | 44 | 45 | [0.3.0]: https://github.com/ztombol/bats-support/compare/v0.2.0...v0.3.0 46 | [0.2.0]: https://github.com/ztombol/bats-support/compare/v0.1.0...v0.2.0 47 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" 2 | source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" 3 | source "$(dirname "${BASH_SOURCE[0]}")/src/lang.bash" 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats-support", 3 | "version": "0.3.0", 4 | "private": true 5 | } 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/script/install-bats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o xtrace 4 | 5 | git clone --depth 1 https://github.com/sstephenson/bats 6 | cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/src/error.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-support - Supporting library for Bats test helpers 3 | # 4 | # Written in 2016 by Zoltan Tombol <zoltan dot tombol at gmail dot com> 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # <http://creativecommons.org/publicdomain/zero/1.0/>. 14 | # 15 | 16 | # 17 | # error.bash 18 | # ---------- 19 | # 20 | # Functions implementing error reporting. Used by public helper 21 | # functions or test suits directly. 22 | # 23 | 24 | # Fail and display a message. When no parameters are specified, the 25 | # message is read from the standard input. Other functions use this to 26 | # report failure. 27 | # 28 | # Globals: 29 | # none 30 | # Arguments: 31 | # $@ - [=STDIN] message 32 | # Returns: 33 | # 1 - always 34 | # Inputs: 35 | # STDIN - [=$@] message 36 | # Outputs: 37 | # STDERR - message 38 | fail() { 39 | (( $# == 0 )) && batslib_err || batslib_err "$@" 40 | return 1 41 | } 42 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/src/lang.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-util - Various auxiliary functions for Bats 3 | # 4 | # Written in 2016 by Zoltan Tombol <zoltan dot tombol at gmail dot com> 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # <http://creativecommons.org/publicdomain/zero/1.0/>. 14 | # 15 | 16 | # 17 | # lang.bash 18 | # --------- 19 | # 20 | # Bash language and execution related functions. Used by public helper 21 | # functions. 22 | # 23 | 24 | # Check whether the calling function was called from a given function. 25 | # 26 | # By default, direct invocation is checked. The function succeeds if the 27 | # calling function was called directly from the given function. In other 28 | # words, if the given function is the next element on the call stack. 29 | # 30 | # When `--indirect' is specified, indirect invocation is checked. The 31 | # function succeeds if the calling function was called from the given 32 | # function with any number of intermediate calls. In other words, if the 33 | # given function can be found somewhere on the call stack. 34 | # 35 | # Direct invocation is a form of indirect invocation with zero 36 | # intermediate calls. 37 | # 38 | # Globals: 39 | # FUNCNAME 40 | # Options: 41 | # -i, --indirect - check indirect invocation 42 | # Arguments: 43 | # $1 - calling function's name 44 | # Returns: 45 | # 0 - current function was called from the given function 46 | # 1 - otherwise 47 | batslib_is_caller() { 48 | local -i is_mode_direct=1 49 | 50 | # Handle options. 51 | while (( $# > 0 )); do 52 | case "$1" in 53 | -i|--indirect) is_mode_direct=0; shift ;; 54 | --) shift; break ;; 55 | *) break ;; 56 | esac 57 | done 58 | 59 | # Arguments. 60 | local -r func="$1" 61 | 62 | # Check call stack. 63 | if (( is_mode_direct )); then 64 | [[ $func == "${FUNCNAME[2]}" ]] && return 0 65 | else 66 | local -i depth 67 | for (( depth=2; depth<${#FUNCNAME[@]}; ++depth )); do 68 | [[ $func == "${FUNCNAME[$depth]}" ]] && return 0 69 | done 70 | fi 71 | 72 | return 1 73 | } 74 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-10-batslib_err.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_err() <message...>: displays <message...>' { 6 | run batslib_err 'm1' 'm2' 7 | [ "$status" -eq 0 ] 8 | [ "$output" == 'm1 m2' ] 9 | } 10 | 11 | @test 'batslib_err(): reads <message...> from STDIN' { 12 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 13 | echo 'm1' 'm2' | batslib_err" 14 | [ "$status" -eq 0 ] 15 | [ "$output" == 'm1 m2' ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-11-batslib_count_lines.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_count_lines() <string>: displays the number of lines in <string>' { 6 | run batslib_count_lines $'a\nb\nc\n' 7 | [ "$status" -eq 0 ] 8 | [ "$output" == '3' ] 9 | } 10 | 11 | @test 'batslib_count_lines() <string>: counts the last line when it is not terminated by a newline' { 12 | run batslib_count_lines $'a\nb\nc' 13 | [ "$status" -eq 0 ] 14 | [ "$output" == '3' ] 15 | } 16 | 17 | @test 'batslib_count_lines() <string>: counts empty lines' { 18 | run batslib_count_lines $'\n\n\n' 19 | [ "$status" -eq 0 ] 20 | [ "$output" == '3' ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-12-batslib_is_single_line.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_is_single_line() <string...>: returns 0 if all <string...> are single-line' { 6 | run batslib_is_single_line 'a' $'b\n' 'c' 7 | [ "$status" -eq 0 ] 8 | } 9 | 10 | @test 'batslib_is_single_line() <string...>: returns 1 if at least one of <string...> is longer than one line' { 11 | run batslib_is_single_line 'a' $'b\nb' 'c' 12 | [ "$status" -eq 1 ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_get_max_single_line_key_width() <pair...>: displays the length of the longest key' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_get_max_single_line_key_width "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "$output" == '5' ] 12 | } 13 | 14 | @test 'batslib_get_max_single_line_key_width() <pair...>: only considers keys with single-line values' { 15 | local -ar pairs=( 'k _1' 'v 1' 16 | 'k 2' 'v 2' 17 | 'k __3' $'v\n3' ) 18 | run batslib_get_max_single_line_key_width "${pairs[@]}" 19 | [ "$status" -eq 0 ] 20 | [ "$output" == '4' ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-14-batslib_print_kv_single.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_single() <width> <pair...>: displays <pair...> in two-column format with <width> wide key column' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2 ' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_single 5 "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '3' ] 12 | [ "${lines[0]}" == 'k _1 : v 1' ] 13 | [ "${lines[1]}" == 'k 2 : v 2' ] 14 | [ "${lines[2]}" == 'k __3 : v 3' ] 15 | } 16 | 17 | @test 'batslib_print_kv_single() <width> <pair...>: does not truncate keys when the column is too narrow' { 18 | local -ar pairs=( 'k _1' 'v 1' 19 | 'k 2' 'v 2' 20 | 'k __3' 'v 3' ) 21 | run batslib_print_kv_single 0 "${pairs[@]}" 22 | [ "$status" -eq 0 ] 23 | [ "${#lines[@]}" == '3' ] 24 | [ "${lines[0]}" == 'k _1 : v 1' ] 25 | [ "${lines[1]}" == 'k 2 : v 2' ] 26 | [ "${lines[2]}" == 'k __3 : v 3' ] 27 | } 28 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-15-batslib_print_kv_multi.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_multi() <pair...>: displays <pair...> in multi-line format' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2' $'v 2-1\nv 2-2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_multi "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '7' ] 12 | [ "${lines[0]}" == 'k _1 (1 lines):' ] 13 | [ "${lines[1]}" == 'v 1' ] 14 | [ "${lines[2]}" == 'k 2 (2 lines):' ] 15 | [ "${lines[3]}" == 'v 2-1' ] 16 | [ "${lines[4]}" == 'v 2-2' ] 17 | [ "${lines[5]}" == 'k __3 (1 lines):' ] 18 | [ "${lines[6]}" == 'v 3' ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_single_or_multi() <width> <pair...>: displays <pair...> in two-column format if all values are one line long' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2 ' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_single_or_multi 5 "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '3' ] 12 | [ "${lines[0]}" == 'k _1 : v 1' ] 13 | [ "${lines[1]}" == 'k 2 : v 2' ] 14 | [ "${lines[2]}" == 'k __3 : v 3' ] 15 | } 16 | 17 | @test 'batslib_print_kv_single_or_multi() <width> <pair...>: displays <pair...> in multi-line format if at least one value is longer than one line' { 18 | local -ar pairs=( 'k _1' 'v 1' 19 | 'k 2' $'v 2-1\nv 2-2' 20 | 'k __3' 'v 3' ) 21 | run batslib_print_kv_single_or_multi 5 "${pairs[@]}" 22 | [ "$status" -eq 0 ] 23 | [ "${#lines[@]}" == '7' ] 24 | [ "${lines[0]}" == 'k _1 (1 lines):' ] 25 | [ "${lines[1]}" == ' v 1' ] 26 | [ "${lines[2]}" == 'k 2 (2 lines):' ] 27 | [ "${lines[3]}" == ' v 2-1' ] 28 | [ "${lines[4]}" == ' v 2-2' ] 29 | [ "${lines[5]}" == 'k __3 (1 lines):' ] 30 | [ "${lines[6]}" == ' v 3' ] 31 | } 32 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-17-batslib_prefix.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_prefix() <prefix>: prefixes each line of the input with <prefix>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | printf 'a\nb\nc\n' | batslib_prefix '_'" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '_a' ] 11 | [ "${lines[1]}" == '_b' ] 12 | [ "${lines[2]}" == '_c' ] 13 | } 14 | 15 | @test 'batslib_prefix() <prefix>: prefixes the last line when it is not terminated by a newline' { 16 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 17 | printf 'a\nb\nc' | batslib_prefix '_'" 18 | [ "$status" -eq 0 ] 19 | [ "${#lines[@]}" -eq 3 ] 20 | [ "${lines[0]}" == '_a' ] 21 | [ "${lines[1]}" == '_b' ] 22 | [ "${lines[2]}" == '_c' ] 23 | } 24 | 25 | @test 'batslib_prefix() <prefix>: prefixes empty lines' { 26 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 27 | printf '\n\n\n' | batslib_prefix '_'" 28 | [ "$status" -eq 0 ] 29 | [ "${#lines[@]}" -eq 3 ] 30 | [ "${lines[0]}" == '_' ] 31 | [ "${lines[1]}" == '_' ] 32 | [ "${lines[2]}" == '_' ] 33 | } 34 | 35 | @test 'batslib_prefix(): <prefix> default to two spaces' { 36 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 37 | printf 'a\nb\nc\n' | batslib_prefix" 38 | [ "$status" -eq 0 ] 39 | [ "${#lines[@]}" -eq 3 ] 40 | [ "${lines[0]}" == ' a' ] 41 | [ "${lines[1]}" == ' b' ] 42 | [ "${lines[2]}" == ' c' ] 43 | } 44 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-18-batslib_mark.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_mark() <mark> <index>: marks the <index>-th line of the input with <mark>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | printf ' a\n b\n c\n' | batslib_mark '>' 0" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '>a' ] 11 | [ "${lines[1]}" == ' b' ] 12 | [ "${lines[2]}" == ' c' ] 13 | } 14 | 15 | @test 'batslib_mark() <mark> <index...>: marks multiple lines when <index...> is in ascending order' { 16 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 17 | printf ' a\n b\n c\n' | batslib_mark '>' 1 2" 18 | [ "$status" -eq 0 ] 19 | [ "${#lines[@]}" -eq 3 ] 20 | [ "${lines[0]}" == ' a' ] 21 | [ "${lines[1]}" == '>b' ] 22 | [ "${lines[2]}" == '>c' ] 23 | } 24 | 25 | @test 'batslib_mark() <mark> <index...>: marks multiple lines when <index...> is in random order' { 26 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 27 | printf ' a\n b\n c\n d\n' | batslib_mark '>' 2 1 3" 28 | [ "$status" -eq 0 ] 29 | [ "${#lines[@]}" -eq 4 ] 30 | [ "${lines[0]}" == ' a' ] 31 | [ "${lines[1]}" == '>b' ] 32 | [ "${lines[2]}" == '>c' ] 33 | [ "${lines[3]}" == '>d' ] 34 | } 35 | 36 | @test 'batslib_mark() <mark> <index...>: ignores duplicate indices' { 37 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 38 | printf ' a\n b\n c\n' | batslib_mark '>' 1 2 1" 39 | [ "$status" -eq 0 ] 40 | [ "${#lines[@]}" -eq 3 ] 41 | [ "${lines[0]}" == ' a' ] 42 | [ "${lines[1]}" == '>b' ] 43 | [ "${lines[2]}" == '>c' ] 44 | } 45 | 46 | @test 'batslib_mark() <mark> <index...>: outputs the input untouched if <mark> is the empty string' { 47 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 48 | printf ' a\n b\n c\n' | batslib_mark '' 1" 49 | [ "$status" -eq 0 ] 50 | [ "${#lines[@]}" -eq 3 ] 51 | [ "${lines[0]}" == ' a' ] 52 | [ "${lines[1]}" == ' b' ] 53 | [ "${lines[2]}" == ' c' ] 54 | } 55 | 56 | @test 'batslib_mark() <mark> <index>: marks the last line when it is not terminated by a newline' { 57 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 58 | printf ' a\n b\n c' | batslib_mark '>' 2" 59 | [ "$status" -eq 0 ] 60 | [ "${#lines[@]}" -eq 3 ] 61 | [ "${lines[0]}" == ' a' ] 62 | [ "${lines[1]}" == ' b' ] 63 | [ "${lines[2]}" == '>c' ] 64 | } 65 | 66 | @test 'batslib_mark() <mark> <index>: does not truncate <mark> if it is longer than the marked line' { 67 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 68 | printf '\n' | batslib_mark '>' 0" 69 | [ "$status" -eq 0 ] 70 | [ "${#lines[@]}" -eq 1 ] 71 | [ "${lines[0]}" == '>' ] 72 | } 73 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/50-output-19-batslib_decorate.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_decorate() <title>: encloses the input in a footer line and a header line containing <title>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | echo 'body' | batslib_decorate 'title'" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '-- title --' ] 11 | [ "${lines[1]}" == 'body' ] 12 | [ "${lines[2]}" == '--' ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/51-error-10-fail.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'fail() <message>: returns 1 and displays <message>' { 6 | run fail 'message' 7 | [ "$status" -eq 1 ] 8 | [ "$output" == 'message' ] 9 | } 10 | 11 | @test 'fail(): reads <message> from STDIN' { 12 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 13 | echo 'message' | fail" 14 | [ "$status" -eq 1 ] 15 | [ "$output" == 'message' ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/52-lang-10-batslib_is_caller.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load 'test_helper' 4 | 5 | 6 | # Test functions 7 | test_func_lvl_2() { 8 | test_func_lvl_1 "$@" 9 | } 10 | 11 | test_func_lvl_1() { 12 | test_func_lvl_0 "$@" 13 | } 14 | 15 | test_func_lvl_0() { 16 | batslib_is_caller "$@" 17 | } 18 | 19 | 20 | # 21 | # Direct invocation 22 | # 23 | 24 | # Interface 25 | @test 'batslib_is_caller() <function>: returns 0 if the current function was called directly from <function>' { 26 | run test_func_lvl_1 test_func_lvl_1 27 | [ "$status" -eq 0 ] 28 | [ "${#lines[@]}" -eq 0 ] 29 | } 30 | 31 | @test 'batslib_is_caller() <function>: returns 1 if the current function was not called directly from <function>' { 32 | run test_func_lvl_0 test_func_lvl_1 33 | [ "$status" -eq 1 ] 34 | [ "${#lines[@]}" -eq 0 ] 35 | } 36 | 37 | # Correctness 38 | @test 'batslib_is_caller() <function>: the current function does not appear on the call stack' { 39 | run test_func_lvl_0 test_func_lvl_0 40 | [ "$status" -eq 1 ] 41 | [ "${#lines[@]}" -eq 0 ] 42 | } 43 | 44 | 45 | # 46 | # Indirect invocation 47 | # 48 | 49 | # Options 50 | test_i_indirect() { 51 | run test_func_lvl_2 "$@" 52 | [ "$status" -eq 0 ] 53 | [ "${#lines[@]}" -eq 0 ] 54 | } 55 | 56 | @test 'batslib_is_caller() -i <function>: enables indirect checking' { 57 | test_i_indirect -i test_func_lvl_2 58 | } 59 | 60 | @test 'batslib_is_caller() --indirect <function>: enables indirect checking' { 61 | test_i_indirect --indirect test_func_lvl_2 62 | } 63 | 64 | # Interface 65 | @test 'batslib_is_caller() --indirect <function>: returns 0 if the current function was called indirectly from <function>' { 66 | run test_func_lvl_2 --indirect test_func_lvl_2 67 | [ "$status" -eq 0 ] 68 | [ "${#lines[@]}" -eq 0 ] 69 | } 70 | 71 | @test 'batslib_is_caller() --indirect <function>: returns 1 if the current function was not called indirectly from <function>' { 72 | run test_func_lvl_1 --indirect test_func_lvl_2 73 | [ "$status" -eq 1 ] 74 | [ "${#lines[@]}" -eq 0 ] 75 | } 76 | 77 | # Correctness 78 | @test 'batslib_is_caller() --indirect <function>: direct invocation is a special case of indirect invocation with zero intermediate calls' { 79 | run test_func_lvl_1 --indirect test_func_lvl_1 80 | [ "$status" -eq 0 ] 81 | [ "${#lines[@]}" -eq 0 ] 82 | } 83 | 84 | @test 'batslib_is_caller() --indirect <function>: the current function does not appear on the call stack' { 85 | run test_func_lvl_0 --indirect test_func_lvl_0 86 | [ "$status" -eq 1 ] 87 | [ "${#lines[@]}" -eq 0 ] 88 | } 89 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats-support/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." 3 | 4 | # Load library. 5 | load '../load' 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sh eol=lf 3 | libexec/* eol=lf 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | script: bin/bats --tap test 3 | notifications: 4 | email: 5 | on_success: never 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Sam Stephenson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/bin/bats: -------------------------------------------------------------------------------- 1 | ../libexec/bats -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | resolve_link() { 5 | $(type -p greadlink readlink | head -1) "$1" 6 | } 7 | 8 | abs_dirname() { 9 | local cwd="$(pwd)" 10 | local path="$1" 11 | 12 | while [ -n "$path" ]; do 13 | cd "${path%/*}" 14 | local name="${path##*/}" 15 | path="$(resolve_link "$name" || true)" 16 | done 17 | 18 | pwd 19 | cd "$cwd" 20 | } 21 | 22 | PREFIX="$1" 23 | if [ -z "$1" ]; then 24 | { echo "usage: $0 <prefix>" 25 | echo " e.g. $0 /usr/local" 26 | } >&2 27 | exit 1 28 | fi 29 | 30 | BATS_ROOT="$(abs_dirname "$0")" 31 | mkdir -p "$PREFIX"/{bin,libexec,share/man/man{1,7}} 32 | cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin 33 | cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec 34 | cp "$BATS_ROOT"/man/bats.1 "$PREFIX"/share/man/man1 35 | cp "$BATS_ROOT"/man/bats.7 "$PREFIX"/share/man/man7 36 | 37 | echo "Installed Bats to $PREFIX/bin/bats" 38 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/libexec/bats-exec-suite: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | count_only_flag="" 5 | if [ "$1" = "-c" ]; then 6 | count_only_flag=1 7 | shift 8 | fi 9 | 10 | extended_syntax_flag="" 11 | if [ "$1" = "-x" ]; then 12 | extended_syntax_flag="-x" 13 | shift 14 | fi 15 | 16 | trap "kill 0; exit 1" int 17 | 18 | count=0 19 | for filename in "$@"; do 20 | let count+="$(bats-exec-test -c "$filename")" 21 | done 22 | 23 | if [ -n "$count_only_flag" ]; then 24 | echo "$count" 25 | exit 26 | fi 27 | 28 | echo "1..$count" 29 | status=0 30 | offset=0 31 | for filename in "$@"; do 32 | index=0 33 | { 34 | IFS= read -r # 1..n 35 | while IFS= read -r line; do 36 | case "$line" in 37 | "begin "* ) 38 | let index+=1 39 | echo "${line/ $index / $(($offset + $index)) }" 40 | ;; 41 | "ok "* | "not ok "* ) 42 | [ -n "$extended_syntax_flag" ] || let index+=1 43 | echo "${line/ $index / $(($offset + $index)) }" 44 | [ "${line:0:6}" != "not ok" ] || status=1 45 | ;; 46 | * ) 47 | echo "$line" 48 | ;; 49 | esac 50 | done 51 | } < <( bats-exec-test $extended_syntax_flag "$filename" ) 52 | offset=$(($offset + $index)) 53 | done 54 | 55 | exit "$status" 56 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/libexec/bats-preprocess: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | encode_name() { 5 | local name="$1" 6 | local result="test_" 7 | 8 | if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then 9 | name="${name//_/-5f}" 10 | name="${name//-/-2d}" 11 | name="${name// /_}" 12 | result+="$name" 13 | else 14 | local length="${#name}" 15 | local char i 16 | 17 | for ((i=0; i<length; i++)); do 18 | char="${name:$i:1}" 19 | if [ "$char" = " " ]; then 20 | result+="_" 21 | elif [[ "$char" =~ [[:alnum:]] ]]; then 22 | result+="$char" 23 | else 24 | result+="$(printf -- "-%02x" \'"$char")" 25 | fi 26 | done 27 | fi 28 | 29 | echo "$result" 30 | } 31 | 32 | tests=() 33 | index=0 34 | pattern='^ *@test *([^ ].*) *\{ *(.*)$' 35 | 36 | while IFS= read -r line; do 37 | let index+=1 38 | if [[ "$line" =~ $pattern ]]; then 39 | quoted_name="${BASH_REMATCH[1]}" 40 | body="${BASH_REMATCH[2]}" 41 | name="$(eval echo "$quoted_name")" 42 | encoded_name="$(encode_name "$name")" 43 | tests["${#tests[@]}"]="$encoded_name" 44 | echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}" 45 | else 46 | printf "%s\n" "$line" 47 | fi 48 | done 49 | 50 | for test_name in "${tests[@]}"; do 51 | echo "bats_test_function ${test_name}" 52 | done 53 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/man/Makefile: -------------------------------------------------------------------------------- 1 | RONN := ronn 2 | PAGES := bats.1 bats.7 3 | 4 | all: $(PAGES) 5 | 6 | bats.1: bats.1.ronn 7 | $(RONN) -r $< 8 | 9 | bats.7: bats.7.ronn 10 | $(RONN) -r $< 11 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/man/README.md: -------------------------------------------------------------------------------- 1 | Bats man pages are generated with [Ronn](http://rtomayko.github.io/ronn/). 2 | 3 | After making changes to `bats.1.ronn` or `bats.7.ronn`, run `make` in 4 | this directory to generate `bats.1` and `bats.7`. **Do not edit the 5 | `bats.1` or `bats.7` files directly.** 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/man/bats.1.ronn: -------------------------------------------------------------------------------- 1 | bats(1) -- Bash Automated Testing System 2 | ======================================== 3 | 4 | 5 | SYNOPSIS 6 | -------- 7 | 8 | bats [-c] [-p | -t] <test> [<test> ...] 9 | 10 | <test> is the path to a Bats test file, or the path to a directory 11 | containing Bats test files. 12 | 13 | 14 | DESCRIPTION 15 | ----------- 16 | 17 | Bats is a TAP-compliant testing framework for Bash. It provides a simple 18 | way to verify that the UNIX programs you write behave as expected. 19 | 20 | A Bats test file is a Bash script with special syntax for defining 21 | test cases. Under the hood, each test case is just a function with a 22 | description. 23 | 24 | Test cases consist of standard shell commands. Bats makes use of 25 | Bash's `errexit` (`set -e`) option when running test cases. If every 26 | command in the test case exits with a `0` status code (success), the 27 | test passes. In this way, each line is an assertion of truth. 28 | 29 | See `bats`(7) for more information on writing Bats tests. 30 | 31 | 32 | RUNNING TESTS 33 | ------------- 34 | 35 | To run your tests, invoke the `bats` interpreter with a path to a test 36 | file. The file's test cases are run sequentially and in isolation. If 37 | all the test cases pass, `bats` exits with a `0` status code. If there 38 | are any failures, `bats` exits with a `1` status code. 39 | 40 | You can invoke the `bats` interpreter with multiple test file arguments, 41 | or with a path to a directory containing multiple `.bats` files. Bats 42 | will run each test file individually and aggregate the results. If any 43 | test case fails, `bats` exits with a `1` status code. 44 | 45 | 46 | OPTIONS 47 | ------- 48 | 49 | * `-c`, `--count`: 50 | Count the number of test cases without running any tests 51 | * `-h`, `--help`: 52 | Display help message 53 | * `-p`, `--pretty`: 54 | Show results in pretty format (default for terminals) 55 | * `-t`, `--tap`: 56 | Show results in TAP format 57 | * `-v`, `--version`: 58 | Display the version number 59 | 60 | 61 | OUTPUT 62 | ------ 63 | 64 | When you run Bats from a terminal, you'll see output as each test is 65 | performed, with a check-mark next to the test's name if it passes or 66 | an "X" if it fails. 67 | 68 | $ bats addition.bats 69 | ✓ addition using bc 70 | ✓ addition using dc 71 | 72 | 2 tests, 0 failures 73 | 74 | If Bats is not connected to a terminal--in other words, if you run it 75 | from a continuous integration system or redirect its output to a 76 | file--the results are displayed in human-readable, machine-parsable 77 | TAP format. You can force TAP output from a terminal by invoking Bats 78 | with the `--tap` option. 79 | 80 | $ bats --tap addition.bats 81 | 1..2 82 | ok 1 addition using bc 83 | ok 2 addition using dc 84 | 85 | 86 | EXIT STATUS 87 | ----------- 88 | 89 | The `bats` interpreter exits with a value of `0` if all test cases pass, 90 | or `1` if one or more test cases fail. 91 | 92 | 93 | SEE ALSO 94 | -------- 95 | 96 | Bats wiki: _https://github.com/sstephenson/bats/wiki/_ 97 | 98 | `bash`(1), `bats`(7) 99 | 100 | 101 | COPYRIGHT 102 | --------- 103 | 104 | (c) 2014 Sam Stephenson 105 | 106 | Bats is released under the terms of an MIT-style license. 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats", 3 | "version": "v0.4.0", 4 | "description": "Bash Automated Testing System", 5 | "install": "./install.sh ${PREFIX:-/usr/local}", 6 | "scripts": [ "libexec/bats", "libexec/bats-exec-suite", "libexec/bats-exec-test", "libexec/bats-format-tap-stream", "libexec/bats-preprocess", "bin/bats" ] 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/dos_line.bats: -------------------------------------------------------------------------------- 1 | @test "foo" { 2 | echo "foo" 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/empty.bats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/empty.bats -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/environment.bats: -------------------------------------------------------------------------------- 1 | @test "setting a variable" { 2 | variable=1 3 | [ $variable -eq 1 ] 4 | } 5 | 6 | @test "variables do not persist across tests" { 7 | [ -z "$variable" ] 8 | } 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/failing.bats: -------------------------------------------------------------------------------- 1 | @test "a failing test" { 2 | true 3 | true 4 | eval "( exit ${STATUS:-1} )" 5 | } 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/failing_and_passing.bats: -------------------------------------------------------------------------------- 1 | @test "a failing test" { 2 | false 3 | } 4 | 5 | @test "a passing test" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/failing_helper.bats: -------------------------------------------------------------------------------- 1 | load "test_helper" 2 | 3 | @test "failing helper function" { 4 | true 5 | failing_helper 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/failing_setup.bats: -------------------------------------------------------------------------------- 1 | setup() { 2 | false 3 | } 4 | 5 | @test "truth" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/failing_teardown.bats: -------------------------------------------------------------------------------- 1 | teardown() { 2 | eval "( exit ${STATUS:-1} )" 3 | } 4 | 5 | @test "truth" { 6 | [ "$PASS" = "1" ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/intact.bats: -------------------------------------------------------------------------------- 1 | @test "dash-e on beginning of line" { 2 | run cat - <<INPUT 3 | -e 4 | INPUT 5 | test "$output" = "-e" 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/invalid_tap.bats: -------------------------------------------------------------------------------- 1 | echo "This isn't TAP!" 2 | echo "Good day to you" 3 | exit 1 4 | 5 | @test "truth" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/load.bats: -------------------------------------------------------------------------------- 1 | [ -n "$HELPER_NAME" ] || HELPER_NAME="test_helper" 2 | load "$HELPER_NAME" 3 | 4 | @test "calling a loaded helper" { 5 | help_me 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/loop_keep_IFS.bats: -------------------------------------------------------------------------------- 1 | # see issue #89 2 | loop_func() { 3 | local search="none one two tree" 4 | local d 5 | 6 | for d in $search ; do 7 | echo $d 8 | done 9 | } 10 | 11 | @test "loop_func" { 12 | run loop_func 13 | [[ "${lines[3]}" == 'tree' ]] 14 | run loop_func 15 | [[ "${lines[2]}" == 'two' ]] 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/output.bats: -------------------------------------------------------------------------------- 1 | @test "success writing to stdout" { 2 | echo "success stdout 1" 3 | echo "success stdout 2" 4 | } 5 | 6 | @test "success writing to stderr" { 7 | echo "success stderr" >&2 8 | } 9 | 10 | @test "failure writing to stdout" { 11 | echo "failure stdout 1" 12 | echo "failure stdout 2" 13 | false 14 | } 15 | 16 | @test "failure writing to stderr" { 17 | echo "failure stderr" >&2 18 | false 19 | } 20 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/passing.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/passing_and_failing.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a failing test" { 6 | false 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/passing_and_skipping.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a skipping test" { 6 | skip 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/passing_failing_and_skipping.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a skipping test" { 6 | skip 7 | } 8 | 9 | @test "a failing test" { 10 | false 11 | } 12 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/setup.bats: -------------------------------------------------------------------------------- 1 | LOG="$TMP/setup.log" 2 | 3 | setup() { 4 | echo "$BATS_TEST_NAME" >> "$LOG" 5 | } 6 | 7 | @test "one" { 8 | [ "$(tail -n 1 "$LOG")" = "test_one" ] 9 | } 10 | 11 | @test "two" { 12 | [ "$(tail -n 1 "$LOG")" = "test_two" ] 13 | } 14 | 15 | @test "three" { 16 | [ "$(tail -n 1 "$LOG")" = "test_three" ] 17 | } 18 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/single_line.bats: -------------------------------------------------------------------------------- 1 | @test "empty" { } 2 | 3 | @test "passing" { true; } 4 | 5 | @test "input redirection" { diff - <( echo hello ); } <<EOS 6 | hello 7 | EOS 8 | 9 | @test "failing" { false; } 10 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/skipped.bats: -------------------------------------------------------------------------------- 1 | @test "a skipped test" { 2 | skip 3 | } 4 | 5 | @test "a skipped test with a reason" { 6 | skip "a reason" 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/teardown.bats: -------------------------------------------------------------------------------- 1 | LOG="$TMP/teardown.log" 2 | 3 | teardown() { 4 | echo "$BATS_TEST_NAME" >> "$LOG" 5 | } 6 | 7 | @test "one" { 8 | true 9 | } 10 | 11 | @test "two" { 12 | false 13 | } 14 | 15 | @test "three" { 16 | true 17 | } 18 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/test_helper.bash: -------------------------------------------------------------------------------- 1 | help_me() { 2 | true 3 | } 4 | 5 | failing_helper() { 6 | false 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/bats/without_trailing_newline.bats: -------------------------------------------------------------------------------- 1 | @test "truth" { 2 | true 3 | } -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/suite/empty/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/suite/empty/.gitkeep -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/suite/multiple/a.bats: -------------------------------------------------------------------------------- 1 | @test "truth" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/suite/multiple/b.bats: -------------------------------------------------------------------------------- 1 | @test "more truth" { 2 | true 3 | } 4 | 5 | @test "quasi-truth" { 6 | [ -z "$FLUNK" ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/fixtures/suite/single/test.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/suite.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | fixtures suite 5 | 6 | @test "running a suite with no test files" { 7 | run bats "$FIXTURE_ROOT/empty" 8 | [ $status -eq 0 ] 9 | [ "$output" = "1..0" ] 10 | } 11 | 12 | @test "running a suite with one test file" { 13 | run bats "$FIXTURE_ROOT/single" 14 | [ $status -eq 0 ] 15 | [ "${lines[0]}" = "1..1" ] 16 | [ "${lines[1]}" = "ok 1 a passing test" ] 17 | } 18 | 19 | @test "counting tests in a suite" { 20 | run bats -c "$FIXTURE_ROOT/single" 21 | [ $status -eq 0 ] 22 | [ "$output" -eq 1 ] 23 | 24 | run bats -c "$FIXTURE_ROOT/multiple" 25 | [ $status -eq 0 ] 26 | [ "$output" -eq 3 ] 27 | } 28 | 29 | @test "aggregated output of multiple tests in a suite" { 30 | run bats "$FIXTURE_ROOT/multiple" 31 | [ $status -eq 0 ] 32 | [ "${lines[0]}" = "1..3" ] 33 | echo "$output" | grep "^ok . truth" 34 | echo "$output" | grep "^ok . more truth" 35 | echo "$output" | grep "^ok . quasi-truth" 36 | } 37 | 38 | @test "a failing test in a suite results in an error exit code" { 39 | FLUNK=1 run bats "$FIXTURE_ROOT/multiple" 40 | [ $status -eq 1 ] 41 | [ "${lines[0]}" = "1..3" ] 42 | echo "$output" | grep "^not ok . quasi-truth" 43 | } 44 | 45 | @test "running an ad-hoc suite by specifying multiple test files" { 46 | run bats "$FIXTURE_ROOT/multiple/a.bats" "$FIXTURE_ROOT/multiple/b.bats" 47 | [ $status -eq 0 ] 48 | [ "${lines[0]}" = "1..3" ] 49 | echo "$output" | grep "^ok . truth" 50 | echo "$output" | grep "^ok . more truth" 51 | echo "$output" | grep "^ok . quasi-truth" 52 | } 53 | 54 | @test "extended syntax in suite" { 55 | FLUNK=1 run bats-exec-suite -x "$FIXTURE_ROOT/multiple/"*.bats 56 | [ $status -eq 1 ] 57 | [ "${lines[0]}" = "1..3" ] 58 | [ "${lines[1]}" = "begin 1 truth" ] 59 | [ "${lines[2]}" = "ok 1 truth" ] 60 | [ "${lines[3]}" = "begin 2 more truth" ] 61 | [ "${lines[4]}" = "ok 2 more truth" ] 62 | [ "${lines[5]}" = "begin 3 quasi-truth" ] 63 | [ "${lines[6]}" = "not ok 3 quasi-truth" ] 64 | } 65 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/libs/bats/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | fixtures() { 2 | FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1" 3 | RELATIVE_FIXTURE_ROOT="$(bats_trim_filename "$FIXTURE_ROOT")" 4 | } 5 | 6 | setup() { 7 | export TMP="$BATS_TEST_DIRNAME/tmp" 8 | } 9 | 10 | filter_control_sequences() { 11 | "$@" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' 12 | } 13 | 14 | teardown() { 15 | [ -d "$TMP" ] && rm -f "$TMP"/* 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/test.bats: -------------------------------------------------------------------------------- 1 | #!./test/libs/bats/bin/bats 2 | 3 | load 'libs/bats-support/load' 4 | load 'libs/bats-assert/load' 5 | 6 | 7 | . test_helper.bash 8 | 9 | @test "check REP balance" { 10 | run seth --from-wei $(seth --to-dec $(seth call $REP 'balanceOf(address)' $ETH_FROM)) eth 11 | assert_line '50.000000000000000000' 12 | } 13 | 14 | @test "approve MCD_JOIN_REP to withdraw 20 REP" { 15 | run seth send $REP 'approve(address,uint)' $MCD_JOIN_REP_A $dink 16 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 17 | } 18 | 19 | @test "Send 20 REP to urn" { 20 | run seth send $MCD_JOIN_REP_A 'join(address,uint)' $urn $dink 21 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 22 | } 23 | 24 | @test "Locking 20 REP and issuing 5 Dai" { 25 | run seth send $CDP_MANAGER 'frob(uint,address,int,int)' 7 $ETH_FROM $dink $dart 26 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 27 | } 28 | 29 | @test "Approving MCD_JOIN_DAI to exit" { 30 | run seth send $MCD_VAT 'hope(address)' $MCD_JOIN_DAI 31 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 32 | } 33 | 34 | @test "Exiting DAI to own wallet address" { 35 | run seth send $MCD_JOIN_DAI 'exit(address,uint)' $ETH_FROM $dart 36 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 37 | } 38 | 39 | @test "Check Dai balance in own wallet" { 40 | run seth --from-wei $(seth --to-dec $(seth call $MCD_DAI 'balanceOf(address)' $ETH_FROM)) 41 | assert_line "5.000000000000000000" 42 | } 43 | 44 | @test "Approving MCD_JOIN_DAI to take DAI from your wallet" { 45 | run seth send $MCD_DAI 'approve(address,uint)' $MCD_JOIN_DAI $dart 46 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 47 | } 48 | 49 | @test "Sending DAI to urn" { 50 | run seth send $MCD_JOIN_DAI 'join(address,uint)' $urn $dart 51 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 52 | } 53 | 54 | @test "Paying back DAI and receving ink to wallet" { 55 | run seth send $CDP_MANAGER 'frob(uint,address,int,int)' 7 $ETH_FROM $nDink $nDart 56 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 57 | } 58 | 59 | @test "Exiting collateral from REP adapter" { 60 | run seth send $MCD_JOIN_REP_A 'exit(address,uint)' $ETH_FROM $dink 61 | [[ "$output" == *"seth-send: Transaction included in block"* ]] 62 | } 63 | 64 | @test "check REP balance" { 65 | run seth --from-wei $(seth --to-dec $(seth call $REP 'balanceOf(address)' $ETH_FROM)) eth 66 | assert_line '50.000000000000000000' 67 | } 68 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth-cdp-manager/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export MCD_CHAIN=kovan 3 | export SETH_CHAIN=kovan 4 | export ETH_FROM=0x18d92ba0b79d769e6b781b92ee2e9d45b3e1e017 5 | export ETH_KEYSTORE=./account/ 6 | export ETH_PASSWORD=./account/pass 7 | export CDP_MANAGER=0x7a4991c6bd1053c31f1678955ce839999d9841b1 8 | export MCD_VAT=0x04c67ea772ebb467383772cb1b64c7a9b1e02bca 9 | export REP=0xc7aa227823789e363f29679f23f7e8f6d9904a9b 10 | export MCD_JOIN_REP_A=0x91f4e07be74445a3897b6d4e70393b5ad7b8e4b0 11 | export MCD_DAI=0xdb6a55a94e0dd324292f3d05cf504c751b31cee2 12 | export MCD_JOIN_DAI=0xcf20652c7e9ff777fcb3772b594e852d1154174d 13 | export ETH_GAS=2000000 14 | export ilk=$(seth --to-bytes32 $(seth --from-ascii "REP-A")) 15 | export urn=$(seth call $CDP_MANAGER 'urns(uint)(address)' 7) 16 | export dink=$(seth --to-uint256 $(seth --to-wei 20 eth)) 17 | export dart=$(seth --to-uint256 $(seth --to-wei 5 eth)) 18 | export nDink=$(seth --to-uint256 $(mcd --to-hex $(seth --to-wei -20 eth))) 19 | export nDart=$(seth --to-uint256 $(mcd --to-hex $(seth --to-wei -5 eth))) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/mcd-seth.MD: -------------------------------------------------------------------------------- 1 | # MCD-SETH Test 2 | 3 | *Version: [0.2.10](https://changelog.makerdao.com/releases/0.2.10/index.html) kovan deployment* 4 | 5 | This test checks the [mcd-seth guide](https://github.com/makerdao/developerguides/blob/master/mcd/mcd-seth/mcd-seth-01.md) against the 0.2.10 mcd realease to see if there's any breaking changes. 6 | The `test` folder has necessary files to run the test. 7 | 8 | Make sure to install the [seth](https://github.com/makerdao/developerguides/blob/master/devtools/seth/seth-guide-01/seth-guide-01.md) tool first before running the test. 9 | 10 | ## Install 11 | 12 | - Linux: `sudo apt install bats` 13 | - Mac: 14 | - Press Command+Space and type Terminal and press enter/return key. 15 | - Run in Terminal app: 16 | `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null` 17 | and press enter/return key. 18 | If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish. 19 | - Run: 20 | `brew install bats` 21 | 22 | ## Steps 23 | 24 | - Navigate to `test` folder 25 | - To run the tests, run `bats test.bats` command and the test will start. 26 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/account/mcd-cli-test-keystore: -------------------------------------------------------------------------------- 1 | {"version":3,"id":"93dd8afb-9925-4622-ae37-4c70d642bb08","address":"18d92ba0b79d769e6b781b92ee2e9d45b3e1e017","crypto":{"ciphertext":"cb90ef46af693ed78da0741f9c03164a8b6773e6db207f9d35624b7e026bc720","cipherparams":{"iv":"2baf3504d167e0c0eeffb499e4b717f6"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"57f47ef42d6ef6f04f7309decf7e7819ff582ed228bcffe9be7ce537c384c9b5","n":8192,"r":8,"p":1},"mac":"ae38a6d51d1bad1230e0ec6de69c6d911810c24d4412d3e2d8560b185a24b799"}} -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/account/pass: -------------------------------------------------------------------------------- 1 | mcd-cli-test 2 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_install: 3 | - ./script/install-bats.sh 4 | - git clone --depth 1 https://github.com/ztombol/bats-support ../bats-support 5 | before_script: 6 | - export PATH="${HOME}/.local/bin:${PATH}" 7 | script: 8 | - bats test 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 7 | ## [0.3.0] - 2016-03-22 8 | 9 | ### Removed 10 | 11 | - Move `fail()` to `bats-support` 12 | 13 | 14 | ## [0.2.0] - 2016-03-11 15 | 16 | ### Added 17 | 18 | - `refute()` to complement `assert()` 19 | - `npm` support 20 | 21 | ### Fixed 22 | 23 | - Not consuming the `--` when stopping option parsing in 24 | `assert_output`, `refute_output`, `assert_line` and `refute_line` 25 | 26 | 27 | ## 0.1.0 - 2016-02-16 28 | 29 | ### Added 30 | 31 | - Reporting arbitrary failures with `fail()` 32 | - Generic assertions with `assert()` and `assert_equal()` 33 | - Testing exit status with `assert_success()` and `assert_failure()` 34 | - Testing output with `assert_output()` and `refute_output()` 35 | - Testing individual lines with `assert_line()` and `refute_line()` 36 | 37 | 38 | [0.3.0]: https://github.com/ztombol/bats-assert/compare/v0.2.0...v0.3.0 39 | [0.2.0]: https://github.com/ztombol/bats-assert/compare/v0.1.0...v0.2.0 40 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash" 2 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats-assert", 3 | "version": "0.3.0", 4 | "private": true, 5 | "peerDependencies": { 6 | "bats-support": "git+https://github.com/ztombol/bats-support.git#v0.2.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/script/install-bats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o xtrace 4 | 5 | git clone --depth 1 https://github.com/sstephenson/bats 6 | cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/test/50-assert-11-assert.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'assert() <expression>: returns 0 if <expression> evaluates to TRUE' { 6 | run assert true 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'assert() <expression>: returns 1 and displays <expression> if it evaluates to FALSE' { 12 | run assert false 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 3 ] 15 | [ "${lines[0]}" == '-- assertion failed --' ] 16 | [ "${lines[1]}" == 'expression : false' ] 17 | [ "${lines[2]}" == '--' ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/test/50-assert-12-assert_equal.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'assert_equal() <actual> <expected>: returns 0 if <actual> equals <expected>' { 6 | run assert_equal 'a' 'a' 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'assert_equal() <actual> <expected>: returns 1 and displays details if <actual> does not equal <expected>' { 12 | run assert_equal 'a' 'b' 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 4 ] 15 | [ "${lines[0]}" == '-- values do not equal --' ] 16 | [ "${lines[1]}" == 'expected : b' ] 17 | [ "${lines[2]}" == 'actual : a' ] 18 | [ "${lines[3]}" == '--' ] 19 | } 20 | 21 | @test 'assert_equal() <actual> <expected>: displays details in multi-line format if <actual> is longer than one line' { 22 | run assert_equal $'a 0\na 1' 'b' 23 | [ "$status" -eq 1 ] 24 | [ "${#lines[@]}" -eq 7 ] 25 | [ "${lines[0]}" == '-- values do not equal --' ] 26 | [ "${lines[1]}" == 'expected (1 lines):' ] 27 | [ "${lines[2]}" == ' b' ] 28 | [ "${lines[3]}" == 'actual (2 lines):' ] 29 | [ "${lines[4]}" == ' a 0' ] 30 | [ "${lines[5]}" == ' a 1' ] 31 | [ "${lines[6]}" == '--' ] 32 | } 33 | 34 | @test 'assert_equal() <actual> <expected>: displays details in multi-line format if <expected> is longer than one line' { 35 | run assert_equal 'a' $'b 0\nb 1' 36 | [ "$status" -eq 1 ] 37 | [ "${#lines[@]}" -eq 7 ] 38 | [ "${lines[0]}" == '-- values do not equal --' ] 39 | [ "${lines[1]}" == 'expected (2 lines):' ] 40 | [ "${lines[2]}" == ' b 0' ] 41 | [ "${lines[3]}" == ' b 1' ] 42 | [ "${lines[4]}" == 'actual (1 lines):' ] 43 | [ "${lines[5]}" == ' a' ] 44 | [ "${lines[6]}" == '--' ] 45 | } 46 | 47 | @test 'assert_equal() <actual> <expected>: performs literal matching' { 48 | run assert_equal 'a' '*' 49 | [ "$status" -eq 1 ] 50 | } 51 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/test/50-assert-13-assert_success.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test "assert_success(): returns 0 if \`\$status' is 0" { 6 | run true 7 | run assert_success 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 0 ] 10 | } 11 | 12 | @test "assert_success(): returns 1 and displays details if \`\$status' is not 0" { 13 | run bash -c 'echo "a" 14 | exit 1' 15 | run assert_success 16 | [ "$status" -eq 1 ] 17 | [ "${#lines[@]}" -eq 4 ] 18 | [ "${lines[0]}" == '-- command failed --' ] 19 | [ "${lines[1]}" == 'status : 1' ] 20 | [ "${lines[2]}" == 'output : a' ] 21 | [ "${lines[3]}" == '--' ] 22 | } 23 | 24 | @test "assert_success(): displays \`\$output' in multi-line format if it is longer than one line" { 25 | run bash -c 'printf "a 0\na 1" 26 | exit 1' 27 | run assert_success 28 | [ "$status" -eq 1 ] 29 | [ "${#lines[@]}" -eq 6 ] 30 | [ "${lines[0]}" == '-- command failed --' ] 31 | [ "${lines[1]}" == 'status : 1' ] 32 | [ "${lines[2]}" == 'output (2 lines):' ] 33 | [ "${lines[3]}" == ' a 0' ] 34 | [ "${lines[4]}" == ' a 1' ] 35 | [ "${lines[5]}" == '--' ] 36 | } 37 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/test/50-assert-14-assert_failure.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test "assert_failure(): returns 0 if \`\$status' is not 0" { 6 | run false 7 | run assert_failure 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 0 ] 10 | } 11 | 12 | @test "assert_failure(): returns 1 and displays details if \`\$status' is 0" { 13 | run bash -c 'echo "a" 14 | exit 0' 15 | run assert_failure 16 | [ "$status" -eq 1 ] 17 | [ "${#lines[@]}" -eq 3 ] 18 | [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] 19 | [ "${lines[1]}" == 'output : a' ] 20 | [ "${lines[2]}" == '--' ] 21 | } 22 | 23 | @test "assert_failure(): displays \`\$output' in multi-line format if it is longer then one line" { 24 | run bash -c 'printf "a 0\na 1" 25 | exit 0' 26 | run assert_failure 27 | [ "$status" -eq 1 ] 28 | [ "${#lines[@]}" -eq 5 ] 29 | [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] 30 | [ "${lines[1]}" == 'output (2 lines):' ] 31 | [ "${lines[2]}" == ' a 0' ] 32 | [ "${lines[3]}" == ' a 1' ] 33 | [ "${lines[4]}" == '--' ] 34 | } 35 | 36 | @test "assert_failure() <status>: returns 0 if \`\$status' equals <status>" { 37 | run bash -c 'exit 1' 38 | run assert_failure 1 39 | [ "$status" -eq 0 ] 40 | [ "${#lines[@]}" -eq 0 ] 41 | } 42 | 43 | @test "assert_failure() <status>: returns 1 and displays details if \`\$status' does not equal <status>" { 44 | run bash -c 'echo "a" 45 | exit 1' 46 | run assert_failure 2 47 | [ "$status" -eq 1 ] 48 | [ "${#lines[@]}" -eq 5 ] 49 | [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] 50 | [ "${lines[1]}" == 'expected : 2' ] 51 | [ "${lines[2]}" == 'actual : 1' ] 52 | [ "${lines[3]}" == 'output : a' ] 53 | [ "${lines[4]}" == '--' ] 54 | } 55 | 56 | @test "assert_failure() <status>: displays \`\$output' in multi-line format if it is longer then one line" { 57 | run bash -c 'printf "a 0\na 1" 58 | exit 1' 59 | run assert_failure 2 60 | [ "$status" -eq 1 ] 61 | [ "${#lines[@]}" -eq 7 ] 62 | [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] 63 | [ "${lines[1]}" == 'expected : 2' ] 64 | [ "${lines[2]}" == 'actual : 1' ] 65 | [ "${lines[3]}" == 'output (2 lines):' ] 66 | [ "${lines[4]}" == ' a 0' ] 67 | [ "${lines[5]}" == ' a 1' ] 68 | [ "${lines[6]}" == '--' ] 69 | } 70 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/test/50-assert-19-refute.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'refute() <expression>: returns 0 if <expression> evaluates to FALSE' { 6 | run refute false 7 | [ "$status" -eq 0 ] 8 | [ "${#lines[@]}" -eq 0 ] 9 | } 10 | 11 | @test 'refute() <expression>: returns 1 and displays <expression> if it evaluates to TRUE' { 12 | run refute true 13 | [ "$status" -eq 1 ] 14 | [ "${#lines[@]}" -eq 3 ] 15 | [ "${lines[0]}" == '-- assertion succeeded, but it was expected to fail --' ] 16 | [ "${lines[1]}" == 'expression : true' ] 17 | [ "${lines[2]}" == '--' ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-assert/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." 3 | export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}" 4 | 5 | # Load dependencies. 6 | load "${TEST_DEPS_DIR}/bats-support/load.bash" 7 | 8 | # Load library. 9 | load '../load' 10 | } 11 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | before_install: 3 | - ./script/install-bats.sh 4 | before_script: 5 | - export PATH="${HOME}/.local/bin:${PATH}" 6 | script: 7 | - bats test 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | 7 | ## [0.3.0] - 2016-11-29 8 | 9 | ### Added 10 | 11 | - Restricting invocation to specific locations with 12 | `batslib_is_caller()` 13 | 14 | 15 | ## [0.2.0] - 2016-03-22 16 | 17 | ### Added 18 | 19 | - `npm` support 20 | - Reporting arbitrary failures with `fail()` (moved from `bats-assert`) 21 | 22 | ### Changed 23 | 24 | - Library renamed to `bats-support` 25 | 26 | 27 | ## 0.1.0 - 2016-02-16 28 | 29 | ### Added 30 | 31 | - Two-column key-value formatting with `batslib_print_kv_single()` 32 | - Multi-line key-value formatting with `batslib_print_kv_multi()` 33 | - Mixed formatting with `batslib_print_kv_single_or_multi()` 34 | - Header and footer decoration with `batslib_decorate()` 35 | - Prefixing lines with `batslib_prefix()` 36 | - Marking lines with `batslib_mark()` 37 | - Common output function `batslib_err()` 38 | - Line counting with `batslib_count_lines()` 39 | - Checking whether a text is one line long with 40 | `batslib_is_single_line()` 41 | - Determining key width for two-column and mixed formatting with 42 | `batslib_get_max_single_line_key_width()` 43 | 44 | 45 | [0.3.0]: https://github.com/ztombol/bats-support/compare/v0.2.0...v0.3.0 46 | [0.2.0]: https://github.com/ztombol/bats-support/compare/v0.1.0...v0.2.0 47 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" 2 | source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" 3 | source "$(dirname "${BASH_SOURCE[0]}")/src/lang.bash" 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats-support", 3 | "version": "0.3.0", 4 | "private": true 5 | } 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/script/install-bats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o xtrace 4 | 5 | git clone --depth 1 https://github.com/sstephenson/bats 6 | cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/src/error.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-support - Supporting library for Bats test helpers 3 | # 4 | # Written in 2016 by Zoltan Tombol <zoltan dot tombol at gmail dot com> 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # <http://creativecommons.org/publicdomain/zero/1.0/>. 14 | # 15 | 16 | # 17 | # error.bash 18 | # ---------- 19 | # 20 | # Functions implementing error reporting. Used by public helper 21 | # functions or test suits directly. 22 | # 23 | 24 | # Fail and display a message. When no parameters are specified, the 25 | # message is read from the standard input. Other functions use this to 26 | # report failure. 27 | # 28 | # Globals: 29 | # none 30 | # Arguments: 31 | # $@ - [=STDIN] message 32 | # Returns: 33 | # 1 - always 34 | # Inputs: 35 | # STDIN - [=$@] message 36 | # Outputs: 37 | # STDERR - message 38 | fail() { 39 | (( $# == 0 )) && batslib_err || batslib_err "$@" 40 | return 1 41 | } 42 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/src/lang.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-util - Various auxiliary functions for Bats 3 | # 4 | # Written in 2016 by Zoltan Tombol <zoltan dot tombol at gmail dot com> 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # <http://creativecommons.org/publicdomain/zero/1.0/>. 14 | # 15 | 16 | # 17 | # lang.bash 18 | # --------- 19 | # 20 | # Bash language and execution related functions. Used by public helper 21 | # functions. 22 | # 23 | 24 | # Check whether the calling function was called from a given function. 25 | # 26 | # By default, direct invocation is checked. The function succeeds if the 27 | # calling function was called directly from the given function. In other 28 | # words, if the given function is the next element on the call stack. 29 | # 30 | # When `--indirect' is specified, indirect invocation is checked. The 31 | # function succeeds if the calling function was called from the given 32 | # function with any number of intermediate calls. In other words, if the 33 | # given function can be found somewhere on the call stack. 34 | # 35 | # Direct invocation is a form of indirect invocation with zero 36 | # intermediate calls. 37 | # 38 | # Globals: 39 | # FUNCNAME 40 | # Options: 41 | # -i, --indirect - check indirect invocation 42 | # Arguments: 43 | # $1 - calling function's name 44 | # Returns: 45 | # 0 - current function was called from the given function 46 | # 1 - otherwise 47 | batslib_is_caller() { 48 | local -i is_mode_direct=1 49 | 50 | # Handle options. 51 | while (( $# > 0 )); do 52 | case "$1" in 53 | -i|--indirect) is_mode_direct=0; shift ;; 54 | --) shift; break ;; 55 | *) break ;; 56 | esac 57 | done 58 | 59 | # Arguments. 60 | local -r func="$1" 61 | 62 | # Check call stack. 63 | if (( is_mode_direct )); then 64 | [[ $func == "${FUNCNAME[2]}" ]] && return 0 65 | else 66 | local -i depth 67 | for (( depth=2; depth<${#FUNCNAME[@]}; ++depth )); do 68 | [[ $func == "${FUNCNAME[$depth]}" ]] && return 0 69 | done 70 | fi 71 | 72 | return 1 73 | } 74 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-10-batslib_err.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_err() <message...>: displays <message...>' { 6 | run batslib_err 'm1' 'm2' 7 | [ "$status" -eq 0 ] 8 | [ "$output" == 'm1 m2' ] 9 | } 10 | 11 | @test 'batslib_err(): reads <message...> from STDIN' { 12 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 13 | echo 'm1' 'm2' | batslib_err" 14 | [ "$status" -eq 0 ] 15 | [ "$output" == 'm1 m2' ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-11-batslib_count_lines.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_count_lines() <string>: displays the number of lines in <string>' { 6 | run batslib_count_lines $'a\nb\nc\n' 7 | [ "$status" -eq 0 ] 8 | [ "$output" == '3' ] 9 | } 10 | 11 | @test 'batslib_count_lines() <string>: counts the last line when it is not terminated by a newline' { 12 | run batslib_count_lines $'a\nb\nc' 13 | [ "$status" -eq 0 ] 14 | [ "$output" == '3' ] 15 | } 16 | 17 | @test 'batslib_count_lines() <string>: counts empty lines' { 18 | run batslib_count_lines $'\n\n\n' 19 | [ "$status" -eq 0 ] 20 | [ "$output" == '3' ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-12-batslib_is_single_line.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_is_single_line() <string...>: returns 0 if all <string...> are single-line' { 6 | run batslib_is_single_line 'a' $'b\n' 'c' 7 | [ "$status" -eq 0 ] 8 | } 9 | 10 | @test 'batslib_is_single_line() <string...>: returns 1 if at least one of <string...> is longer than one line' { 11 | run batslib_is_single_line 'a' $'b\nb' 'c' 12 | [ "$status" -eq 1 ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_get_max_single_line_key_width() <pair...>: displays the length of the longest key' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_get_max_single_line_key_width "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "$output" == '5' ] 12 | } 13 | 14 | @test 'batslib_get_max_single_line_key_width() <pair...>: only considers keys with single-line values' { 15 | local -ar pairs=( 'k _1' 'v 1' 16 | 'k 2' 'v 2' 17 | 'k __3' $'v\n3' ) 18 | run batslib_get_max_single_line_key_width "${pairs[@]}" 19 | [ "$status" -eq 0 ] 20 | [ "$output" == '4' ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-14-batslib_print_kv_single.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_single() <width> <pair...>: displays <pair...> in two-column format with <width> wide key column' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2 ' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_single 5 "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '3' ] 12 | [ "${lines[0]}" == 'k _1 : v 1' ] 13 | [ "${lines[1]}" == 'k 2 : v 2' ] 14 | [ "${lines[2]}" == 'k __3 : v 3' ] 15 | } 16 | 17 | @test 'batslib_print_kv_single() <width> <pair...>: does not truncate keys when the column is too narrow' { 18 | local -ar pairs=( 'k _1' 'v 1' 19 | 'k 2' 'v 2' 20 | 'k __3' 'v 3' ) 21 | run batslib_print_kv_single 0 "${pairs[@]}" 22 | [ "$status" -eq 0 ] 23 | [ "${#lines[@]}" == '3' ] 24 | [ "${lines[0]}" == 'k _1 : v 1' ] 25 | [ "${lines[1]}" == 'k 2 : v 2' ] 26 | [ "${lines[2]}" == 'k __3 : v 3' ] 27 | } 28 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-15-batslib_print_kv_multi.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_multi() <pair...>: displays <pair...> in multi-line format' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2' $'v 2-1\nv 2-2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_multi "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '7' ] 12 | [ "${lines[0]}" == 'k _1 (1 lines):' ] 13 | [ "${lines[1]}" == 'v 1' ] 14 | [ "${lines[2]}" == 'k 2 (2 lines):' ] 15 | [ "${lines[3]}" == 'v 2-1' ] 16 | [ "${lines[4]}" == 'v 2-2' ] 17 | [ "${lines[5]}" == 'k __3 (1 lines):' ] 18 | [ "${lines[6]}" == 'v 3' ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_print_kv_single_or_multi() <width> <pair...>: displays <pair...> in two-column format if all values are one line long' { 6 | local -ar pairs=( 'k _1' 'v 1' 7 | 'k 2 ' 'v 2' 8 | 'k __3' 'v 3' ) 9 | run batslib_print_kv_single_or_multi 5 "${pairs[@]}" 10 | [ "$status" -eq 0 ] 11 | [ "${#lines[@]}" == '3' ] 12 | [ "${lines[0]}" == 'k _1 : v 1' ] 13 | [ "${lines[1]}" == 'k 2 : v 2' ] 14 | [ "${lines[2]}" == 'k __3 : v 3' ] 15 | } 16 | 17 | @test 'batslib_print_kv_single_or_multi() <width> <pair...>: displays <pair...> in multi-line format if at least one value is longer than one line' { 18 | local -ar pairs=( 'k _1' 'v 1' 19 | 'k 2' $'v 2-1\nv 2-2' 20 | 'k __3' 'v 3' ) 21 | run batslib_print_kv_single_or_multi 5 "${pairs[@]}" 22 | [ "$status" -eq 0 ] 23 | [ "${#lines[@]}" == '7' ] 24 | [ "${lines[0]}" == 'k _1 (1 lines):' ] 25 | [ "${lines[1]}" == ' v 1' ] 26 | [ "${lines[2]}" == 'k 2 (2 lines):' ] 27 | [ "${lines[3]}" == ' v 2-1' ] 28 | [ "${lines[4]}" == ' v 2-2' ] 29 | [ "${lines[5]}" == 'k __3 (1 lines):' ] 30 | [ "${lines[6]}" == ' v 3' ] 31 | } 32 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-17-batslib_prefix.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_prefix() <prefix>: prefixes each line of the input with <prefix>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | printf 'a\nb\nc\n' | batslib_prefix '_'" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '_a' ] 11 | [ "${lines[1]}" == '_b' ] 12 | [ "${lines[2]}" == '_c' ] 13 | } 14 | 15 | @test 'batslib_prefix() <prefix>: prefixes the last line when it is not terminated by a newline' { 16 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 17 | printf 'a\nb\nc' | batslib_prefix '_'" 18 | [ "$status" -eq 0 ] 19 | [ "${#lines[@]}" -eq 3 ] 20 | [ "${lines[0]}" == '_a' ] 21 | [ "${lines[1]}" == '_b' ] 22 | [ "${lines[2]}" == '_c' ] 23 | } 24 | 25 | @test 'batslib_prefix() <prefix>: prefixes empty lines' { 26 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 27 | printf '\n\n\n' | batslib_prefix '_'" 28 | [ "$status" -eq 0 ] 29 | [ "${#lines[@]}" -eq 3 ] 30 | [ "${lines[0]}" == '_' ] 31 | [ "${lines[1]}" == '_' ] 32 | [ "${lines[2]}" == '_' ] 33 | } 34 | 35 | @test 'batslib_prefix(): <prefix> default to two spaces' { 36 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 37 | printf 'a\nb\nc\n' | batslib_prefix" 38 | [ "$status" -eq 0 ] 39 | [ "${#lines[@]}" -eq 3 ] 40 | [ "${lines[0]}" == ' a' ] 41 | [ "${lines[1]}" == ' b' ] 42 | [ "${lines[2]}" == ' c' ] 43 | } 44 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-18-batslib_mark.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_mark() <mark> <index>: marks the <index>-th line of the input with <mark>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | printf ' a\n b\n c\n' | batslib_mark '>' 0" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '>a' ] 11 | [ "${lines[1]}" == ' b' ] 12 | [ "${lines[2]}" == ' c' ] 13 | } 14 | 15 | @test 'batslib_mark() <mark> <index...>: marks multiple lines when <index...> is in ascending order' { 16 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 17 | printf ' a\n b\n c\n' | batslib_mark '>' 1 2" 18 | [ "$status" -eq 0 ] 19 | [ "${#lines[@]}" -eq 3 ] 20 | [ "${lines[0]}" == ' a' ] 21 | [ "${lines[1]}" == '>b' ] 22 | [ "${lines[2]}" == '>c' ] 23 | } 24 | 25 | @test 'batslib_mark() <mark> <index...>: marks multiple lines when <index...> is in random order' { 26 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 27 | printf ' a\n b\n c\n d\n' | batslib_mark '>' 2 1 3" 28 | [ "$status" -eq 0 ] 29 | [ "${#lines[@]}" -eq 4 ] 30 | [ "${lines[0]}" == ' a' ] 31 | [ "${lines[1]}" == '>b' ] 32 | [ "${lines[2]}" == '>c' ] 33 | [ "${lines[3]}" == '>d' ] 34 | } 35 | 36 | @test 'batslib_mark() <mark> <index...>: ignores duplicate indices' { 37 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 38 | printf ' a\n b\n c\n' | batslib_mark '>' 1 2 1" 39 | [ "$status" -eq 0 ] 40 | [ "${#lines[@]}" -eq 3 ] 41 | [ "${lines[0]}" == ' a' ] 42 | [ "${lines[1]}" == '>b' ] 43 | [ "${lines[2]}" == '>c' ] 44 | } 45 | 46 | @test 'batslib_mark() <mark> <index...>: outputs the input untouched if <mark> is the empty string' { 47 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 48 | printf ' a\n b\n c\n' | batslib_mark '' 1" 49 | [ "$status" -eq 0 ] 50 | [ "${#lines[@]}" -eq 3 ] 51 | [ "${lines[0]}" == ' a' ] 52 | [ "${lines[1]}" == ' b' ] 53 | [ "${lines[2]}" == ' c' ] 54 | } 55 | 56 | @test 'batslib_mark() <mark> <index>: marks the last line when it is not terminated by a newline' { 57 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 58 | printf ' a\n b\n c' | batslib_mark '>' 2" 59 | [ "$status" -eq 0 ] 60 | [ "${#lines[@]}" -eq 3 ] 61 | [ "${lines[0]}" == ' a' ] 62 | [ "${lines[1]}" == ' b' ] 63 | [ "${lines[2]}" == '>c' ] 64 | } 65 | 66 | @test 'batslib_mark() <mark> <index>: does not truncate <mark> if it is longer than the marked line' { 67 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 68 | printf '\n' | batslib_mark '>' 0" 69 | [ "$status" -eq 0 ] 70 | [ "${#lines[@]}" -eq 1 ] 71 | [ "${lines[0]}" == '>' ] 72 | } 73 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/50-output-19-batslib_decorate.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'batslib_decorate() <title>: encloses the input in a footer line and a header line containing <title>' { 6 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 7 | echo 'body' | batslib_decorate 'title'" 8 | [ "$status" -eq 0 ] 9 | [ "${#lines[@]}" -eq 3 ] 10 | [ "${lines[0]}" == '-- title --' ] 11 | [ "${lines[1]}" == 'body' ] 12 | [ "${lines[2]}" == '--' ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/51-error-10-fail.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | 5 | @test 'fail() <message>: returns 1 and displays <message>' { 6 | run fail 'message' 7 | [ "$status" -eq 1 ] 8 | [ "$output" == 'message' ] 9 | } 10 | 11 | @test 'fail(): reads <message> from STDIN' { 12 | run bash -c "source '${TEST_MAIN_DIR}/load.bash' 13 | echo 'message' | fail" 14 | [ "$status" -eq 1 ] 15 | [ "$output" == 'message' ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/52-lang-10-batslib_is_caller.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load 'test_helper' 4 | 5 | 6 | # Test functions 7 | test_func_lvl_2() { 8 | test_func_lvl_1 "$@" 9 | } 10 | 11 | test_func_lvl_1() { 12 | test_func_lvl_0 "$@" 13 | } 14 | 15 | test_func_lvl_0() { 16 | batslib_is_caller "$@" 17 | } 18 | 19 | 20 | # 21 | # Direct invocation 22 | # 23 | 24 | # Interface 25 | @test 'batslib_is_caller() <function>: returns 0 if the current function was called directly from <function>' { 26 | run test_func_lvl_1 test_func_lvl_1 27 | [ "$status" -eq 0 ] 28 | [ "${#lines[@]}" -eq 0 ] 29 | } 30 | 31 | @test 'batslib_is_caller() <function>: returns 1 if the current function was not called directly from <function>' { 32 | run test_func_lvl_0 test_func_lvl_1 33 | [ "$status" -eq 1 ] 34 | [ "${#lines[@]}" -eq 0 ] 35 | } 36 | 37 | # Correctness 38 | @test 'batslib_is_caller() <function>: the current function does not appear on the call stack' { 39 | run test_func_lvl_0 test_func_lvl_0 40 | [ "$status" -eq 1 ] 41 | [ "${#lines[@]}" -eq 0 ] 42 | } 43 | 44 | 45 | # 46 | # Indirect invocation 47 | # 48 | 49 | # Options 50 | test_i_indirect() { 51 | run test_func_lvl_2 "$@" 52 | [ "$status" -eq 0 ] 53 | [ "${#lines[@]}" -eq 0 ] 54 | } 55 | 56 | @test 'batslib_is_caller() -i <function>: enables indirect checking' { 57 | test_i_indirect -i test_func_lvl_2 58 | } 59 | 60 | @test 'batslib_is_caller() --indirect <function>: enables indirect checking' { 61 | test_i_indirect --indirect test_func_lvl_2 62 | } 63 | 64 | # Interface 65 | @test 'batslib_is_caller() --indirect <function>: returns 0 if the current function was called indirectly from <function>' { 66 | run test_func_lvl_2 --indirect test_func_lvl_2 67 | [ "$status" -eq 0 ] 68 | [ "${#lines[@]}" -eq 0 ] 69 | } 70 | 71 | @test 'batslib_is_caller() --indirect <function>: returns 1 if the current function was not called indirectly from <function>' { 72 | run test_func_lvl_1 --indirect test_func_lvl_2 73 | [ "$status" -eq 1 ] 74 | [ "${#lines[@]}" -eq 0 ] 75 | } 76 | 77 | # Correctness 78 | @test 'batslib_is_caller() --indirect <function>: direct invocation is a special case of indirect invocation with zero intermediate calls' { 79 | run test_func_lvl_1 --indirect test_func_lvl_1 80 | [ "$status" -eq 0 ] 81 | [ "${#lines[@]}" -eq 0 ] 82 | } 83 | 84 | @test 'batslib_is_caller() --indirect <function>: the current function does not appear on the call stack' { 85 | run test_func_lvl_0 --indirect test_func_lvl_0 86 | [ "$status" -eq 1 ] 87 | [ "${#lines[@]}" -eq 0 ] 88 | } 89 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats-support/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | setup() { 2 | export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." 3 | 4 | # Load library. 5 | load '../load' 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sh eol=lf 3 | libexec/* eol=lf 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | script: bin/bats --tap test 3 | notifications: 4 | email: 5 | on_success: never 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Sam Stephenson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/bin/bats: -------------------------------------------------------------------------------- 1 | ../libexec/bats -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | resolve_link() { 5 | $(type -p greadlink readlink | head -1) "$1" 6 | } 7 | 8 | abs_dirname() { 9 | local cwd="$(pwd)" 10 | local path="$1" 11 | 12 | while [ -n "$path" ]; do 13 | cd "${path%/*}" 14 | local name="${path##*/}" 15 | path="$(resolve_link "$name" || true)" 16 | done 17 | 18 | pwd 19 | cd "$cwd" 20 | } 21 | 22 | PREFIX="$1" 23 | if [ -z "$1" ]; then 24 | { echo "usage: $0 <prefix>" 25 | echo " e.g. $0 /usr/local" 26 | } >&2 27 | exit 1 28 | fi 29 | 30 | BATS_ROOT="$(abs_dirname "$0")" 31 | mkdir -p "$PREFIX"/{bin,libexec,share/man/man{1,7}} 32 | cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin 33 | cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec 34 | cp "$BATS_ROOT"/man/bats.1 "$PREFIX"/share/man/man1 35 | cp "$BATS_ROOT"/man/bats.7 "$PREFIX"/share/man/man7 36 | 37 | echo "Installed Bats to $PREFIX/bin/bats" 38 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/libexec/bats-exec-suite: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | count_only_flag="" 5 | if [ "$1" = "-c" ]; then 6 | count_only_flag=1 7 | shift 8 | fi 9 | 10 | extended_syntax_flag="" 11 | if [ "$1" = "-x" ]; then 12 | extended_syntax_flag="-x" 13 | shift 14 | fi 15 | 16 | trap "kill 0; exit 1" int 17 | 18 | count=0 19 | for filename in "$@"; do 20 | let count+="$(bats-exec-test -c "$filename")" 21 | done 22 | 23 | if [ -n "$count_only_flag" ]; then 24 | echo "$count" 25 | exit 26 | fi 27 | 28 | echo "1..$count" 29 | status=0 30 | offset=0 31 | for filename in "$@"; do 32 | index=0 33 | { 34 | IFS= read -r # 1..n 35 | while IFS= read -r line; do 36 | case "$line" in 37 | "begin "* ) 38 | let index+=1 39 | echo "${line/ $index / $(($offset + $index)) }" 40 | ;; 41 | "ok "* | "not ok "* ) 42 | [ -n "$extended_syntax_flag" ] || let index+=1 43 | echo "${line/ $index / $(($offset + $index)) }" 44 | [ "${line:0:6}" != "not ok" ] || status=1 45 | ;; 46 | * ) 47 | echo "$line" 48 | ;; 49 | esac 50 | done 51 | } < <( bats-exec-test $extended_syntax_flag "$filename" ) 52 | offset=$(($offset + $index)) 53 | done 54 | 55 | exit "$status" 56 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/libexec/bats-preprocess: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | encode_name() { 5 | local name="$1" 6 | local result="test_" 7 | 8 | if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then 9 | name="${name//_/-5f}" 10 | name="${name//-/-2d}" 11 | name="${name// /_}" 12 | result+="$name" 13 | else 14 | local length="${#name}" 15 | local char i 16 | 17 | for ((i=0; i<length; i++)); do 18 | char="${name:$i:1}" 19 | if [ "$char" = " " ]; then 20 | result+="_" 21 | elif [[ "$char" =~ [[:alnum:]] ]]; then 22 | result+="$char" 23 | else 24 | result+="$(printf -- "-%02x" \'"$char")" 25 | fi 26 | done 27 | fi 28 | 29 | echo "$result" 30 | } 31 | 32 | tests=() 33 | index=0 34 | pattern='^ *@test *([^ ].*) *\{ *(.*)$' 35 | 36 | while IFS= read -r line; do 37 | let index+=1 38 | if [[ "$line" =~ $pattern ]]; then 39 | quoted_name="${BASH_REMATCH[1]}" 40 | body="${BASH_REMATCH[2]}" 41 | name="$(eval echo "$quoted_name")" 42 | encoded_name="$(encode_name "$name")" 43 | tests["${#tests[@]}"]="$encoded_name" 44 | echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}" 45 | else 46 | printf "%s\n" "$line" 47 | fi 48 | done 49 | 50 | for test_name in "${tests[@]}"; do 51 | echo "bats_test_function ${test_name}" 52 | done 53 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/man/Makefile: -------------------------------------------------------------------------------- 1 | RONN := ronn 2 | PAGES := bats.1 bats.7 3 | 4 | all: $(PAGES) 5 | 6 | bats.1: bats.1.ronn 7 | $(RONN) -r $< 8 | 9 | bats.7: bats.7.ronn 10 | $(RONN) -r $< 11 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/man/README.md: -------------------------------------------------------------------------------- 1 | Bats man pages are generated with [Ronn](http://rtomayko.github.io/ronn/). 2 | 3 | After making changes to `bats.1.ronn` or `bats.7.ronn`, run `make` in 4 | this directory to generate `bats.1` and `bats.7`. **Do not edit the 5 | `bats.1` or `bats.7` files directly.** 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/man/bats.1.ronn: -------------------------------------------------------------------------------- 1 | bats(1) -- Bash Automated Testing System 2 | ======================================== 3 | 4 | 5 | SYNOPSIS 6 | -------- 7 | 8 | bats [-c] [-p | -t] <test> [<test> ...] 9 | 10 | <test> is the path to a Bats test file, or the path to a directory 11 | containing Bats test files. 12 | 13 | 14 | DESCRIPTION 15 | ----------- 16 | 17 | Bats is a TAP-compliant testing framework for Bash. It provides a simple 18 | way to verify that the UNIX programs you write behave as expected. 19 | 20 | A Bats test file is a Bash script with special syntax for defining 21 | test cases. Under the hood, each test case is just a function with a 22 | description. 23 | 24 | Test cases consist of standard shell commands. Bats makes use of 25 | Bash's `errexit` (`set -e`) option when running test cases. If every 26 | command in the test case exits with a `0` status code (success), the 27 | test passes. In this way, each line is an assertion of truth. 28 | 29 | See `bats`(7) for more information on writing Bats tests. 30 | 31 | 32 | RUNNING TESTS 33 | ------------- 34 | 35 | To run your tests, invoke the `bats` interpreter with a path to a test 36 | file. The file's test cases are run sequentially and in isolation. If 37 | all the test cases pass, `bats` exits with a `0` status code. If there 38 | are any failures, `bats` exits with a `1` status code. 39 | 40 | You can invoke the `bats` interpreter with multiple test file arguments, 41 | or with a path to a directory containing multiple `.bats` files. Bats 42 | will run each test file individually and aggregate the results. If any 43 | test case fails, `bats` exits with a `1` status code. 44 | 45 | 46 | OPTIONS 47 | ------- 48 | 49 | * `-c`, `--count`: 50 | Count the number of test cases without running any tests 51 | * `-h`, `--help`: 52 | Display help message 53 | * `-p`, `--pretty`: 54 | Show results in pretty format (default for terminals) 55 | * `-t`, `--tap`: 56 | Show results in TAP format 57 | * `-v`, `--version`: 58 | Display the version number 59 | 60 | 61 | OUTPUT 62 | ------ 63 | 64 | When you run Bats from a terminal, you'll see output as each test is 65 | performed, with a check-mark next to the test's name if it passes or 66 | an "X" if it fails. 67 | 68 | $ bats addition.bats 69 | ✓ addition using bc 70 | ✓ addition using dc 71 | 72 | 2 tests, 0 failures 73 | 74 | If Bats is not connected to a terminal--in other words, if you run it 75 | from a continuous integration system or redirect its output to a 76 | file--the results are displayed in human-readable, machine-parsable 77 | TAP format. You can force TAP output from a terminal by invoking Bats 78 | with the `--tap` option. 79 | 80 | $ bats --tap addition.bats 81 | 1..2 82 | ok 1 addition using bc 83 | ok 2 addition using dc 84 | 85 | 86 | EXIT STATUS 87 | ----------- 88 | 89 | The `bats` interpreter exits with a value of `0` if all test cases pass, 90 | or `1` if one or more test cases fail. 91 | 92 | 93 | SEE ALSO 94 | -------- 95 | 96 | Bats wiki: _https://github.com/sstephenson/bats/wiki/_ 97 | 98 | `bash`(1), `bats`(7) 99 | 100 | 101 | COPYRIGHT 102 | --------- 103 | 104 | (c) 2014 Sam Stephenson 105 | 106 | Bats is released under the terms of an MIT-style license. 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bats", 3 | "version": "v0.4.0", 4 | "description": "Bash Automated Testing System", 5 | "install": "./install.sh ${PREFIX:-/usr/local}", 6 | "scripts": [ "libexec/bats", "libexec/bats-exec-suite", "libexec/bats-exec-test", "libexec/bats-format-tap-stream", "libexec/bats-preprocess", "bin/bats" ] 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/dos_line.bats: -------------------------------------------------------------------------------- 1 | @test "foo" { 2 | echo "foo" 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/empty.bats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/empty.bats -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/environment.bats: -------------------------------------------------------------------------------- 1 | @test "setting a variable" { 2 | variable=1 3 | [ $variable -eq 1 ] 4 | } 5 | 6 | @test "variables do not persist across tests" { 7 | [ -z "$variable" ] 8 | } 9 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/failing.bats: -------------------------------------------------------------------------------- 1 | @test "a failing test" { 2 | true 3 | true 4 | eval "( exit ${STATUS:-1} )" 5 | } 6 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/failing_and_passing.bats: -------------------------------------------------------------------------------- 1 | @test "a failing test" { 2 | false 3 | } 4 | 5 | @test "a passing test" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/failing_helper.bats: -------------------------------------------------------------------------------- 1 | load "test_helper" 2 | 3 | @test "failing helper function" { 4 | true 5 | failing_helper 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/failing_setup.bats: -------------------------------------------------------------------------------- 1 | setup() { 2 | false 3 | } 4 | 5 | @test "truth" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/failing_teardown.bats: -------------------------------------------------------------------------------- 1 | teardown() { 2 | eval "( exit ${STATUS:-1} )" 3 | } 4 | 5 | @test "truth" { 6 | [ "$PASS" = "1" ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/intact.bats: -------------------------------------------------------------------------------- 1 | @test "dash-e on beginning of line" { 2 | run cat - <<INPUT 3 | -e 4 | INPUT 5 | test "$output" = "-e" 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/invalid_tap.bats: -------------------------------------------------------------------------------- 1 | echo "This isn't TAP!" 2 | echo "Good day to you" 3 | exit 1 4 | 5 | @test "truth" { 6 | true 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/load.bats: -------------------------------------------------------------------------------- 1 | [ -n "$HELPER_NAME" ] || HELPER_NAME="test_helper" 2 | load "$HELPER_NAME" 3 | 4 | @test "calling a loaded helper" { 5 | help_me 6 | } 7 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/loop_keep_IFS.bats: -------------------------------------------------------------------------------- 1 | # see issue #89 2 | loop_func() { 3 | local search="none one two tree" 4 | local d 5 | 6 | for d in $search ; do 7 | echo $d 8 | done 9 | } 10 | 11 | @test "loop_func" { 12 | run loop_func 13 | [[ "${lines[3]}" == 'tree' ]] 14 | run loop_func 15 | [[ "${lines[2]}" == 'two' ]] 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/output.bats: -------------------------------------------------------------------------------- 1 | @test "success writing to stdout" { 2 | echo "success stdout 1" 3 | echo "success stdout 2" 4 | } 5 | 6 | @test "success writing to stderr" { 7 | echo "success stderr" >&2 8 | } 9 | 10 | @test "failure writing to stdout" { 11 | echo "failure stdout 1" 12 | echo "failure stdout 2" 13 | false 14 | } 15 | 16 | @test "failure writing to stderr" { 17 | echo "failure stderr" >&2 18 | false 19 | } 20 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/passing.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/passing_and_failing.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a failing test" { 6 | false 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/passing_and_skipping.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a skipping test" { 6 | skip 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/passing_failing_and_skipping.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | 5 | @test "a skipping test" { 6 | skip 7 | } 8 | 9 | @test "a failing test" { 10 | false 11 | } 12 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/setup.bats: -------------------------------------------------------------------------------- 1 | LOG="$TMP/setup.log" 2 | 3 | setup() { 4 | echo "$BATS_TEST_NAME" >> "$LOG" 5 | } 6 | 7 | @test "one" { 8 | [ "$(tail -n 1 "$LOG")" = "test_one" ] 9 | } 10 | 11 | @test "two" { 12 | [ "$(tail -n 1 "$LOG")" = "test_two" ] 13 | } 14 | 15 | @test "three" { 16 | [ "$(tail -n 1 "$LOG")" = "test_three" ] 17 | } 18 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/single_line.bats: -------------------------------------------------------------------------------- 1 | @test "empty" { } 2 | 3 | @test "passing" { true; } 4 | 5 | @test "input redirection" { diff - <( echo hello ); } <<EOS 6 | hello 7 | EOS 8 | 9 | @test "failing" { false; } 10 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/skipped.bats: -------------------------------------------------------------------------------- 1 | @test "a skipped test" { 2 | skip 3 | } 4 | 5 | @test "a skipped test with a reason" { 6 | skip "a reason" 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/teardown.bats: -------------------------------------------------------------------------------- 1 | LOG="$TMP/teardown.log" 2 | 3 | teardown() { 4 | echo "$BATS_TEST_NAME" >> "$LOG" 5 | } 6 | 7 | @test "one" { 8 | true 9 | } 10 | 11 | @test "two" { 12 | false 13 | } 14 | 15 | @test "three" { 16 | true 17 | } 18 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/test_helper.bash: -------------------------------------------------------------------------------- 1 | help_me() { 2 | true 3 | } 4 | 5 | failing_helper() { 6 | false 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/bats/without_trailing_newline.bats: -------------------------------------------------------------------------------- 1 | @test "truth" { 2 | true 3 | } -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/suite/empty/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/tests/mcd/mcd-seth/test/libs/bats/test/fixtures/suite/empty/.gitkeep -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/suite/multiple/a.bats: -------------------------------------------------------------------------------- 1 | @test "truth" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/suite/multiple/b.bats: -------------------------------------------------------------------------------- 1 | @test "more truth" { 2 | true 3 | } 4 | 5 | @test "quasi-truth" { 6 | [ -z "$FLUNK" ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/fixtures/suite/single/test.bats: -------------------------------------------------------------------------------- 1 | @test "a passing test" { 2 | true 3 | } 4 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/suite.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load test_helper 4 | fixtures suite 5 | 6 | @test "running a suite with no test files" { 7 | run bats "$FIXTURE_ROOT/empty" 8 | [ $status -eq 0 ] 9 | [ "$output" = "1..0" ] 10 | } 11 | 12 | @test "running a suite with one test file" { 13 | run bats "$FIXTURE_ROOT/single" 14 | [ $status -eq 0 ] 15 | [ "${lines[0]}" = "1..1" ] 16 | [ "${lines[1]}" = "ok 1 a passing test" ] 17 | } 18 | 19 | @test "counting tests in a suite" { 20 | run bats -c "$FIXTURE_ROOT/single" 21 | [ $status -eq 0 ] 22 | [ "$output" -eq 1 ] 23 | 24 | run bats -c "$FIXTURE_ROOT/multiple" 25 | [ $status -eq 0 ] 26 | [ "$output" -eq 3 ] 27 | } 28 | 29 | @test "aggregated output of multiple tests in a suite" { 30 | run bats "$FIXTURE_ROOT/multiple" 31 | [ $status -eq 0 ] 32 | [ "${lines[0]}" = "1..3" ] 33 | echo "$output" | grep "^ok . truth" 34 | echo "$output" | grep "^ok . more truth" 35 | echo "$output" | grep "^ok . quasi-truth" 36 | } 37 | 38 | @test "a failing test in a suite results in an error exit code" { 39 | FLUNK=1 run bats "$FIXTURE_ROOT/multiple" 40 | [ $status -eq 1 ] 41 | [ "${lines[0]}" = "1..3" ] 42 | echo "$output" | grep "^not ok . quasi-truth" 43 | } 44 | 45 | @test "running an ad-hoc suite by specifying multiple test files" { 46 | run bats "$FIXTURE_ROOT/multiple/a.bats" "$FIXTURE_ROOT/multiple/b.bats" 47 | [ $status -eq 0 ] 48 | [ "${lines[0]}" = "1..3" ] 49 | echo "$output" | grep "^ok . truth" 50 | echo "$output" | grep "^ok . more truth" 51 | echo "$output" | grep "^ok . quasi-truth" 52 | } 53 | 54 | @test "extended syntax in suite" { 55 | FLUNK=1 run bats-exec-suite -x "$FIXTURE_ROOT/multiple/"*.bats 56 | [ $status -eq 1 ] 57 | [ "${lines[0]}" = "1..3" ] 58 | [ "${lines[1]}" = "begin 1 truth" ] 59 | [ "${lines[2]}" = "ok 1 truth" ] 60 | [ "${lines[3]}" = "begin 2 more truth" ] 61 | [ "${lines[4]}" = "ok 2 more truth" ] 62 | [ "${lines[5]}" = "begin 3 quasi-truth" ] 63 | [ "${lines[6]}" = "not ok 3 quasi-truth" ] 64 | } 65 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/libs/bats/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | fixtures() { 2 | FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1" 3 | RELATIVE_FIXTURE_ROOT="$(bats_trim_filename "$FIXTURE_ROOT")" 4 | } 5 | 6 | setup() { 7 | export TMP="$BATS_TEST_DIRNAME/tmp" 8 | } 9 | 10 | filter_control_sequences() { 11 | "$@" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' 12 | } 13 | 14 | teardown() { 15 | [ -d "$TMP" ] && rm -f "$TMP"/* 16 | } 17 | -------------------------------------------------------------------------------- /tests/mcd/mcd-seth/test/test_helper.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export MCD_CHAIN=kovan 3 | export SETH_CHAIN=kovan 4 | export ETH_FROM=0x18d92ba0b79d769e6b781b92ee2e9d45b3e1e017 5 | export ETH_KEYSTORE=./account/ 6 | export ETH_PASSWORD=./account/pass 7 | export REP=0xc7aa227823789e363f29679f23f7e8f6d9904a9b 8 | export DAI_TOKEN=0x5944413037920674d39049ec4844117a031eaa74 9 | export MCD_JOIN_REP_A=0x7d9d701e87920a1a7396438769b571fb55b6ffdc 10 | export MCD_VAT=0x5ce1e3c8ba1363c7a87f5e9118aac0db4b0f0691 11 | export MCD_JOIN_DAI=0xe70a5307f5132ee3a6a056c5efb7d5a53f3cdbd7 12 | export urn=$ETH_FROM 13 | export wad=$(seth --to-uint256 $(seth --to-wei 10 eth)) 14 | export ilk=$(seth --to-bytes32 $(seth --from-ascii "REP-A")) 15 | export dink=$(seth --to-uint256 $(seth --to-hex $(seth --to-wei 10 eth))) 16 | export dart=$(seth --to-uint256 $(seth --to-hex $(seth --to-wei 35 eth))) 17 | export minus10hex=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7538DCFB76180000 18 | export minus35hex=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE1A4705701D540000 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tests", 3 | "version": "1.0.0", 4 | "description": "This folder is intended to keep track of any breaking changes in the source code that resides in our guides.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "jest": "^24.8.0" 14 | }, 15 | "dependencies": { 16 | "@makerdao/dai": "^0.15.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vault/README.md: -------------------------------------------------------------------------------- 1 | # Vault 2 | 3 | Maker Vaults allow users to lock collateral and generate Dai. 4 | 5 | ## Getting Started 6 | 7 | ## Beginner 8 | 9 | ## Intermediate 10 | 11 | - [Vault Integration Guide](/vault/vault-integration-guide/vault-integration-guide.md) 12 | 13 | - [Monitoring Collateral Types and Vaults](/vault/monitoring-collateral-types-and-vaults/monitoring-collateral-types-and-vaults.md) 14 | 15 | ## Advanced 16 | -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/DepositETH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/DepositETH.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/GenerateDAI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/GenerateDAI.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/OpenVaultGenerateDai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/OpenVaultGenerateDai.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/PayBackAllDAIAndWithdrawETH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/PayBackAllDAIAndWithdrawETH.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/PayBackDai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/PayBackDai.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/SetupDSProxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/SetupDSProxy.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/SingleETHVaultUserFlow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/SingleETHVaultUserFlow.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/WithdrawETH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/WithdrawETH.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/img/cdpguide-package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerdao/developerguides/9ded1b68228e6cd70885f1326349c6bf087b9573/vault/vault-integration-guide/img/cdpguide-package.png -------------------------------------------------------------------------------- /vault/vault-integration-guide/sequence-diagrams/README.md: -------------------------------------------------------------------------------- 1 | # Vault Integration Guide - DSProxy Sequence Diagrams 2 | 3 | ## Setup DSProxy 4 | 5 | ![Package](../img/SetupDSProxy.png) 6 | 7 | --- 8 | 9 | ## Open Vault and Generate Dai 10 | 11 | ![Package](../img/OpenVaultGenerateDai.png) 12 | 13 | --- 14 | 15 | ## Deposit ETH 16 | 17 | ![Package](../img/DepositETH.png) 18 | 19 | --- 20 | 21 | ## Withdraw ETH 22 | 23 | ![Package](../img/WithdrawETH.png) 24 | 25 | --- 26 | 27 | ## Generate DAI 28 | 29 | ![Package](../img/GenerateDAI.png) 30 | 31 | --- 32 | 33 | ## Pay back DAI 34 | 35 | ![Package](../img/PayBackDai.png) 36 | 37 | --- 38 | 39 | ## Pay back all DAI and Withdraw ETH 40 | 41 | ![Package](../img/PayBackAllDAIAndWithdrawETH.png) 42 | --------------------------------------------------------------------------------