summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Lee <64482439+algojohnlee@users.noreply.github.com>2021-08-02 15:44:06 -0400
committerGitHub <noreply@github.com>2021-08-02 15:44:06 -0400
commitde84e90e84febadb8224591f8d4ad1551044b0b1 (patch)
tree6a93eea43d9359014c54e46f32f3eaffe2d011a3
parent7e09c41c548c41d0ff349abf5814c5837029dd2f (diff)
parenta35256c0b002e550f727d2bd9ccc10dfaa7bbacf (diff)
Merge pull request #2670 from Algo-devops-service/relbeta2.9.0v2.9.0-beta
go-algorand 2.9.0-beta
-rw-r--r--.circleci/config.yml632
-rw-r--r--.github/ISSUE_TEMPLATE/algorand-engineering-team-issue-template.md21
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md17
-rw-r--r--.golangci.yml16
-rw-r--r--.travis.yml4
-rw-r--r--Makefile14
-rw-r--r--agreement/bundle_test.go13
-rw-r--r--agreement/certificate_test.go21
-rw-r--r--agreement/cryptoRequestContext_test.go21
-rw-r--r--agreement/cryptoVerifier_test.go3
-rw-r--r--agreement/demux_test.go3
-rw-r--r--agreement/encoding_test.go3
-rw-r--r--agreement/fuzzer/tests_test.go10
-rw-r--r--agreement/gossip/networkFull_test.go6
-rw-r--r--agreement/gossip/network_test.go3
-rw-r--r--agreement/msgp_gen_test.go18
-rw-r--r--agreement/persistence_test.go5
-rw-r--r--agreement/player_permutation_test.go3
-rw-r--r--agreement/player_test.go105
-rw-r--r--agreement/proposal.go4
-rw-r--r--agreement/proposalManager_test.go19
-rw-r--r--agreement/proposalStore_test.go22
-rw-r--r--agreement/proposalTracker_test.go5
-rw-r--r--agreement/proposal_test.go7
-rw-r--r--agreement/pseudonode_test.go5
-rw-r--r--agreement/service_test.go50
-rw-r--r--agreement/voteAggregator_test.go35
-rw-r--r--agreement/voteAuxiliary_test.go21
-rw-r--r--agreement/voteTracker_test.go35
-rw-r--r--agreement/vote_test.go10
-rw-r--r--catchup/ledgerFetcher_test.go7
-rw-r--r--catchup/peerSelector_test.go22
-rw-r--r--catchup/service.go3
-rw-r--r--catchup/service_test.go25
-rw-r--r--catchup/universalFetcher_test.go10
-rw-r--r--cmd/goal/account.go4
-rw-r--r--cmd/goal/messages.go2
-rw-r--r--cmd/goal/node.go6
-rw-r--r--cmd/partitiontest_linter/go.mod5
-rw-r--r--cmd/partitiontest_linter/go.sum27
-rw-r--r--cmd/partitiontest_linter/linter.go132
-rw-r--r--cmd/partitiontest_linter/linter_test.go27
-rw-r--r--cmd/partitiontest_linter/plugin/plugin.go (renamed from util/metrics/gaugeCommon.go)32
-rw-r--r--cmd/partitiontest_linter/testdata/linter_testdata_test.go73
-rw-r--r--cmd/tealdbg/cdtState.go2
-rw-r--r--cmd/tealdbg/localLedger.go18
-rw-r--r--compactcert/db_test.go3
-rw-r--r--compactcert/msgp_gen_test.go2
-rw-r--r--compactcert/worker_test.go13
-rw-r--r--config/config_test.go38
-rw-r--r--config/consensus.go5
-rw-r--r--config/consensus_test.go5
-rw-r--r--config/version.go2
-rw-r--r--crypto/compactcert/bigfloat_test.go5
-rw-r--r--crypto/compactcert/builder_test.go5
-rw-r--r--crypto/compactcert/common_test.go5
-rw-r--r--crypto/compactcert/msgp_gen_test.go7
-rw-r--r--crypto/merklearray/layer_test.go3
-rw-r--r--crypto/merklearray/merkle_test.go3
-rw-r--r--crypto/merkletrie/bitset_test.go5
-rw-r--r--crypto/merkletrie/cache_test.go23
-rw-r--r--crypto/merkletrie/committer_test.go9
-rw-r--r--crypto/merkletrie/node_test.go3
-rw-r--r--crypto/merkletrie/trie_test.go5
-rw-r--r--crypto/msgp_gen_test.go26
-rw-r--r--crypto/passphrase/passphrase_test.go13
-rw-r--r--daemon/algod/api/server/router_test.go12
-rw-r--r--daemon/algod/api/server/v2/handlers.go2
-rw-r--r--daemon/algod/api/server/v2/test/handlers_test.go100
-rw-r--r--daemon/algod/api/server/v2/test/helpers.go12
-rw-r--r--daemon/algod/api/server/v2/utils.go2
-rw-r--r--daemon/algod/deadlock_test.go5
-rw-r--r--daemon/algod/server_test.go7
-rw-r--r--daemon/kmd/config/config.go6
-rw-r--r--daemon/kmd/wallet/driver/ledger.go13
-rw-r--r--daemon/kmd/wallet/driver/ledger_hid.go3
-rw-r--r--data/account/participation_test.go5
-rw-r--r--data/basics/address_test.go17
-rw-r--r--data/basics/msgp_gen_test.go14
-rw-r--r--data/basics/teal_test.go9
-rw-r--r--data/basics/units_test.go5
-rw-r--r--data/basics/userBalance_test.go11
-rw-r--r--data/bookkeeping/block_test.go31
-rw-r--r--data/bookkeeping/encoding_test.go5
-rw-r--r--data/bookkeeping/msgp_gen_test.go8
-rw-r--r--data/bookkeeping/txn_merkle_test.go5
-rw-r--r--data/committee/credential_test.go17
-rw-r--r--data/committee/encoding_test.go3
-rw-r--r--data/committee/msgp_gen_test.go5
-rw-r--r--data/hashable/msgp_gen_test.go2
-rw-r--r--data/ledger_test.go7
-rw-r--r--data/pools/transactionPool_test.go31
-rw-r--r--data/transactions/application_test.go7
-rw-r--r--data/transactions/logic/README.md2
-rw-r--r--data/transactions/logic/TEAL_opcodes.md16
-rw-r--r--data/transactions/logic/assembler.go56
-rw-r--r--data/transactions/logic/assembler_test.go104
-rw-r--r--data/transactions/logic/backwardCompat_test.go9
-rw-r--r--data/transactions/logic/debugger_test.go9
-rw-r--r--data/transactions/logic/doc.go6
-rw-r--r--data/transactions/logic/doc_test.go17
-rw-r--r--data/transactions/logic/eval.go31
-rw-r--r--data/transactions/logic/evalStateful_test.go41
-rw-r--r--data/transactions/logic/eval_test.go242
-rw-r--r--data/transactions/logic/opcodes.go2
-rw-r--r--data/transactions/logic/opcodes_test.go8
-rw-r--r--data/transactions/msgp_gen_test.go17
-rw-r--r--data/transactions/payment_test.go3
-rw-r--r--data/transactions/payset_test.go5
-rw-r--r--data/transactions/signedtxn_test.go7
-rw-r--r--data/transactions/transaction.go8
-rw-r--r--data/transactions/transaction_test.go62
-rw-r--r--data/transactions/verify/txn_test.go13
-rw-r--r--data/transactions/verify/verifiedTxnCache_test.go11
-rw-r--r--debug/doberman/main.go3
-rw-r--r--go.mod2
-rw-r--r--go.sum5
-rw-r--r--installer/algorand@.service.template1
-rw-r--r--ledger/accountdb_test.go11
-rw-r--r--ledger/acctupdates.go1
-rw-r--r--ledger/acctupdates_test.go26
-rw-r--r--ledger/appcow.go25
-rw-r--r--ledger/appcow_test.go33
-rw-r--r--ledger/applications_test.go29
-rw-r--r--ledger/apply/application.go35
-rw-r--r--ledger/apply/application_test.go232
-rw-r--r--ledger/apply/apply.go17
-rw-r--r--ledger/apply/asset.go21
-rw-r--r--ledger/apply/asset_test.go3
-rw-r--r--ledger/apply/keyreg_test.go19
-rw-r--r--ledger/apply/mockBalances_test.go14
-rw-r--r--ledger/apply/payment_test.go11
-rw-r--r--ledger/archival_test.go9
-rw-r--r--ledger/assetcow.go48
-rw-r--r--ledger/blockdb_test.go7
-rw-r--r--ledger/blockqueue_test.go5
-rw-r--r--ledger/bulletin_test.go3
-rw-r--r--ledger/catchpointwriter_test.go9
-rw-r--r--ledger/catchupaccessor_test.go9
-rw-r--r--ledger/compactcert_test.go7
-rw-r--r--ledger/cow.go20
-rw-r--r--ledger/cow_test.go5
-rw-r--r--ledger/eval.go68
-rw-r--r--ledger/eval_test.go19
-rw-r--r--ledger/ledger_test.go35
-rw-r--r--ledger/ledgercore/catchpointlabel_test.go7
-rw-r--r--ledger/ledgercore/msgp_gen_test.go3
-rw-r--r--ledger/ledgercore/statedelta.go3
-rw-r--r--ledger/ledgercore/statedelta_test.go3
-rw-r--r--ledger/ledgercore/totals_test.go11
-rw-r--r--ledger/lruaccts_test.go9
-rw-r--r--ledger/msgp_gen_test.go4
-rw-r--r--ledger/onlineacct_test.go9
-rw-r--r--ledger/roundlru_test.go5
-rw-r--r--ledger/txtail_test.go3
-rw-r--r--logging/log.go4
-rw-r--r--logging/telemetry.go3
-rw-r--r--netdeploy/networkTemplates_test.go9
-rw-r--r--netdeploy/network_test.go5
-rw-r--r--netdeploy/remote/bootstrappedNetwork_test.go3
-rw-r--r--netdeploy/remote/deployedNetwork_test.go5
-rw-r--r--network/connPerfMon_test.go5
-rw-r--r--network/limited_reader_slurper_test.go9
-rw-r--r--network/msgOfInterest_test.go5
-rw-r--r--network/multiplexer_test.go3
-rw-r--r--network/phonebook_test.go23
-rw-r--r--network/ping_test.go3
-rw-r--r--network/requestLogger_test.go3
-rw-r--r--network/requestTracker_test.go7
-rw-r--r--network/topics_test.go3
-rw-r--r--network/wsNetwork_test.go59
-rw-r--r--network/wsPeer_test.go9
-rw-r--r--node/assemble_test.go3
-rw-r--r--node/indexer/indexer_test.go3
-rw-r--r--node/msgp_gen_test.go3
-rw-r--r--node/node.go2
-rw-r--r--node/node_test.go11
-rw-r--r--node/topAccountListener_test.go9
-rw-r--r--nodecontrol/algodControl_test.go5
-rw-r--r--package-deploy.yaml25
-rw-r--r--package-test.yaml24
-rw-r--r--package.yaml18
-rw-r--r--protocol/codec_test.go37
-rw-r--r--protocol/codec_tester.go12
-rw-r--r--protocol/test/allocbound_slice.go26
-rw-r--r--protocol/test/msgp_gen.go87
-rw-r--r--protocol/test/msgp_gen_test.go73
-rw-r--r--protocol/transcode/core_test.go7
-rw-r--r--rpcs/blockService.go2
-rw-r--r--rpcs/blockService_test.go8
-rw-r--r--rpcs/ledgerService.go2
-rw-r--r--rpcs/msgp_gen_test.go2
-rw-r--r--rpcs/txService_test.go3
-rw-r--r--rpcs/txSyncer_test.go18
-rw-r--r--scripts/buildtools/go.mod2
-rw-r--r--scripts/buildtools/go.sum4
-rwxr-xr-xscripts/configure_dev.sh16
-rwxr-xr-xscripts/release/build/rpm/docker.sh1
-rwxr-xr-xscripts/release/build/stage/build/task.sh6
-rwxr-xr-xscripts/release/build/stage/package/task.sh1
-rwxr-xr-xscripts/release/mule/test/test.sh6
-rwxr-xr-xscripts/release/prod/rpm/run_centos.sh6
-rwxr-xr-xscripts/release/test/rpm/run_centos.sh5
-rwxr-xr-xscripts/travis/before_build.sh6
-rwxr-xr-xscripts/travis/build.sh11
-rwxr-xr-xscripts/travis/configure_dev.sh8
-rwxr-xr-xscripts/travis/test.sh11
-rw-r--r--shared/pingpong/accounts.go1
-rw-r--r--shared/pingpong/pingpong.go5
-rw-r--r--test/commandandcontrol/cc_agent/component/agent_test.go3
-rw-r--r--test/e2e-go/cli/algod/cleanup_test.go3
-rw-r--r--test/e2e-go/cli/algod/stdstreams_test.go3
-rw-r--r--test/e2e-go/cli/tealdbg/cdtmock/main.go8
-rw-r--r--test/e2e-go/features/catchup/basicCatchup_test.go7
-rw-r--r--test/e2e-go/features/catchup/catchpointCatchup_test.go3
-rw-r--r--test/e2e-go/features/compactcert/compactcert_test.go3
-rw-r--r--test/e2e-go/features/multisig/multisig_test.go9
-rw-r--r--test/e2e-go/features/participation/onlineOfflineParticipation_test.go4
-rw-r--r--test/e2e-go/features/participation/overlappingParticipationKeys_test.go3
-rw-r--r--test/e2e-go/features/participation/participationRewards_test.go13
-rw-r--r--test/e2e-go/features/partitionRecovery/partitionRecovery_test.go11
-rw-r--r--test/e2e-go/features/teal/compile_test.go3
-rw-r--r--test/e2e-go/features/transactions/accountv2_test.go3
-rw-r--r--test/e2e-go/features/transactions/asset_test.go15
-rw-r--r--test/e2e-go/features/transactions/close_account_test.go3
-rw-r--r--test/e2e-go/features/transactions/group_test.go7
-rw-r--r--test/e2e-go/features/transactions/lease_test.go13
-rw-r--r--test/e2e-go/features/transactions/onlineStatusChange_test.go5
-rw-r--r--test/e2e-go/features/transactions/proof_test.go3
-rw-r--r--test/e2e-go/features/transactions/sendReceive_test.go3
-rw-r--r--test/e2e-go/kmd/e2e_kmd_server_client_test.go7
-rw-r--r--test/e2e-go/kmd/e2e_kmd_sqlite_test.go5
-rw-r--r--test/e2e-go/kmd/e2e_kmd_wallet_keyops_test.go17
-rw-r--r--test/e2e-go/kmd/e2e_kmd_wallet_multisig_test.go13
-rw-r--r--test/e2e-go/kmd/e2e_kmd_wallet_test.go13
-rw-r--r--test/e2e-go/restAPI/restClient_test.go95
-rw-r--r--test/e2e-go/stress/transactions/createManyAndGoOnline_test.go3
-rw-r--r--test/e2e-go/upgrades/application_support_test.go5
-rw-r--r--test/e2e-go/upgrades/rekey_support_test.go3
-rw-r--r--test/e2e-go/upgrades/send_receive_upgrade_test.go11
-rw-r--r--test/framework/fixtures/expectFixture.go3
-rw-r--r--test/framework/fixtures/libgoalFixture.go6
-rw-r--r--test/heapwatch/metrics_delta.py22
-rw-r--r--test/partitiontest/filtering.go55
-rwxr-xr-xtest/scripts/e2e.sh8
-rwxr-xr-xtest/scripts/e2e_subs/e2e-app-extra-pages.sh35
-rwxr-xr-xtest/scripts/e2e_subs/serial/rest-proof-endpoint.sh4
-rw-r--r--tools/network/dnssec/anchor_test.go3
-rw-r--r--tools/network/dnssec/client_test.go5
-rw-r--r--tools/network/dnssec/config_test.go3
-rw-r--r--tools/network/dnssec/config_unix_test.go5
-rw-r--r--tools/network/dnssec/dnssec_test.go11
-rw-r--r--tools/network/dnssec/sort_test.go3
-rw-r--r--tools/network/dnssec/trustedchain_test.go11
-rw-r--r--tools/network/dnssec/trustedzone_test.go9
-rw-r--r--tools/network/dnssec/util_test.go5
-rw-r--r--tools/network/resolveController_test.go9
-rw-r--r--tools/network/resolver_test.go3
-rw-r--r--tools/network/telemetryURIUpdateService_test.go2
-rw-r--r--util/bloom/bloom_test.go23
-rw-r--r--util/codecs/json_test.go3
-rw-r--r--util/db/dbutil_test.go15
-rw-r--r--util/db/versioning_test.go3
-rw-r--r--util/metrics/counter_test.go6
-rw-r--r--util/metrics/gauge.go56
-rw-r--r--util/metrics/gauge_test.go2
-rw-r--r--util/metrics/registry_test.go3
-rwxr-xr-xutil/metrics/reporter_test.go3
-rw-r--r--util/metrics/segment_test.go3
-rw-r--r--util/metrics/stringGauge_test.go3
-rw-r--r--util/metrics/tagcounter_test.go3
-rw-r--r--util/s3/s3Helper_test.go15
-rw-r--r--util/timers/monotonic_test.go11
273 files changed, 4350 insertions, 433 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index f54db5324..0d75f568a 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,8 +1,634 @@
version: 2.1
+
orbs:
- welcome: circleci/welcome-orb@0.4.1
+ win: circleci/windows@2.3.0
+ go: circleci/go@1.7.0
+
workflows:
- welcome:
+ version: 2
+ build_pr:
jobs:
- - welcome/run
+ - codegen_verification
+ - amd64_build
+ - amd64_test:
+ requires:
+ - amd64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - amd64_test_nightly:
+ requires:
+ - amd64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - amd64_integration:
+ requires:
+ - amd64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - amd64_integration_nightly:
+ requires:
+ - amd64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - amd64_e2e_subs:
+ requires:
+ - amd64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - amd64_e2e_subs_nightly:
+ requires:
+ - amd64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - arm64_build
+ - arm64_test:
+ requires:
+ - arm64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - arm64_test_nightly:
+ requires:
+ - arm64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - arm64_integration:
+ requires:
+ - arm64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - arm64_integration_nightly:
+ requires:
+ - arm64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - arm64_e2e_subs:
+ requires:
+ - arm64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - arm64_e2e_subs_nightly:
+ requires:
+ - arm64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - mac_amd64_build
+ - mac_amd64_test:
+ requires:
+ - mac_amd64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - mac_amd64_test_nightly:
+ requires:
+ - mac_amd64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - mac_amd64_integration:
+ requires:
+ - mac_amd64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - mac_amd64_integration_nightly:
+ requires:
+ - mac_amd64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ - mac_amd64_e2e_subs:
+ requires:
+ - mac_amd64_build
+ filters:
+ branches:
+ ignore: "rel/nightly"
+ - mac_amd64_e2e_subs_nightly:
+ requires:
+ - mac_amd64_build
+ filters:
+ branches:
+ only: "rel/nightly"
+ #- windows_x64_build
+
+commands:
+ prepare_go:
+ description: Clean out existing Go so we can use our preferred version
+ parameters:
+ circleci_home:
+ type: string
+ default: "/home/circleci"
+ steps:
+ - run: |
+ sudo rm -rf << parameters.circleci_home >>/.go_workspace /usr/local/go
+ prepare_windows:
+ description: Prepare windows image
+ parameters:
+ circleci_home:
+ type: string
+ default: "/home/circleci"
+ steps:
+ - run:
+ name: install deps
+ shell: bash.exe
+ command: |
+ choco install -y msys2 pacman make wget --force
+ choco install -y golang --version=1.14.7 --force
+ choco install -y python3 --version=3.7.3 --force
+ export msys2='cmd //C RefreshEnv.cmd '
+ export msys2+='& set MSYS=winsymlinks:nativestrict '
+ export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
+ export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
+ export msys2+=" -msys2 -c "\"\$@"\" --"
+ $msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-libtool unzip autoconf automake
+
+ generic_build:
+ description: Run basic build and store in workspace for re-use by different architectures
+ parameters:
+ circleci_home:
+ type: string
+ default: "/home/circleci"
+ steps:
+ - restore_libsodium
+ - restore_cache:
+ keys:
+ - 'go-mod-1-14-7-v1-{{ arch }}-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}'
+ - restore_cache:
+ keys:
+ - 'go-cache-{{ .Environment.CIRCLE_STAGE }}-'
+ - run:
+ name: scripts/travis/build.sh --make_debug
+ command: |
+ export PATH=$(echo "$PATH" | sed -e 's|:<< parameters.circleci_home >>/\.go_workspace/bin||g' | sed -e 's|:/usr/local/go/bin||g')
+ export GOPATH="<< parameters.circleci_home >>/go"
+ export ALGORAND_DEADLOCK=enable
+ scripts/travis/build.sh --make_debug
+ - cache_libsodium
+ - save_cache:
+ key: 'go-mod-1-14-7-v1-{{ arch }}-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}'
+ paths:
+ - << parameters.circleci_home >>/go/pkg/mod
+ - save_cache:
+ key: 'go-cache-{{ .Environment.CIRCLE_STAGE }}-{{ .Environment.CIRCLE_BUILD_NUM }}'
+ paths:
+ - tmp/go-cache
+ - persist_to_workspace:
+ root: << parameters.circleci_home >>
+ paths:
+ - project
+ - go
+ - gimme
+ - .gimme
+
+ cache_libsodium:
+ description: Cache libsodium for build
+ steps:
+ - run:
+ name: Get libsodium md5
+ command: |
+ mkdir -p tmp
+ find crypto/libsodium-fork -type f -exec openssl md5 "{}" + > tmp/libsodium.md5
+ - save_cache:
+ key: 'libsodium-fork-{{ .Environment.CIRCLE_STAGE }}-{{ checksum "tmp/libsodium.md5" }}'
+ paths:
+ - crypto/libs
+
+ restore_libsodium:
+ description: Restore libsodium for build
+ steps:
+ - run:
+ name: Get libsodium md5
+ command: |
+ mkdir -p tmp
+ find crypto/libsodium-fork -type f -exec openssl md5 "{}" + > tmp/libsodium.md5
+ - restore_cache:
+ keys:
+ - 'libsodium-fork-{{ .Environment.CIRCLE_STAGE }}-{{ checksum "tmp/libsodium.md5" }}'
+
+ generic_buildtest:
+ description: Run build tests from build workspace, for re-use by diferent architectures
+ parameters:
+ circleci_home:
+ type: string
+ default: "/home/circleci"
+ result_subdir:
+ type: string
+ no_output_timeout:
+ type: string
+ default: 30m
+ short_test_flag:
+ type: string
+ default: ""
+ steps:
+ - attach_workspace:
+ at: << parameters.circleci_home >>
+ - run: mkdir -p /tmp/results/<< parameters.result_subdir >>
+ - restore_cache:
+ keys:
+ - 'go-cache-{{ .Environment.CIRCLE_STAGE }}-'
+ - run:
+ name: Run build tests
+ no_output_timeout: << parameters.no_output_timeout >>
+ command: |
+ set -e
+ set -x
+ export PATH=$(echo "$PATH" | sed -e 's|:<< parameters.circleci_home >>/\.go_workspace/bin||g' | sed -e 's|:/usr/local/go/bin||g')
+ export KMD_NOUSB=True
+ export GOPATH="<< parameters.circleci_home >>/go"
+ export PATH="${PATH}:${GOPATH}/bin"
+ export ALGORAND_DEADLOCK=enable
+ GOLANG_VERSION=$(./scripts/get_golang_version.sh)
+ eval "$(~/gimme "${GOLANG_VERSION}")"
+ scripts/configure_dev.sh
+ scripts/buildtools/install_buildtools.sh -o "gotest.tools/gotestsum"
+ PACKAGES="$(go list ./... | grep -v /go-algorand/test/)"
+ export PACKAGE_NAMES=$(echo $PACKAGES | tr -d '\n')
+ export PARTITION_TOTAL=$CIRCLE_NODE_TOTAL
+ export PARTITION_ID=$CIRCLE_NODE_INDEX
+ export PARALLEL_FLAG="-p 1"
+ gotestsum --format pkgname --junitfile /tmp/results/<< parameters.result_subdir >>/results.xml --jsonfile /tmp/results/<< parameters.result_subdir >>/testresults.json -- --tags "sqlite_unlock_notify sqlite_omit_load_extension" << parameters.short_test_flag >> -race -timeout 1h -coverprofile=coverage.txt -covermode=atomic -p 1 $PACKAGE_NAMES
+ - store_artifacts:
+ path: /tmp/results
+ destination: test-results
+ - store_test_results:
+ path: /tmp/results
+ - save_cache:
+ key: 'go-cache-{{ .Environment.CIRCLE_STAGE }}-{{ .Environment.CIRCLE_BUILD_NUM }}'
+ paths:
+ - tmp/go-cache
+
+ upload_coverage:
+ description: Collect coverage reports and upload them
+ steps:
+ - run:
+ name: Upload Coverage Reports
+ no_output_timeout: 10m
+ command: |
+ scripts/travis/upload_coverage.sh || true
+
+ generic_integration:
+ description: Run integration tests from build workspace, for re-use by diferent architectures
+ parameters:
+ circleci_home:
+ type: string
+ default: "/home/circleci"
+ result_subdir:
+ type: string
+ no_output_timeout:
+ type: string
+ default: 30m
+ short_test_flag:
+ type: string
+ default: ""
+ steps:
+ - attach_workspace:
+ at: << parameters.circleci_home >>
+ - run: mkdir -p /tmp/results/<< parameters.result_subdir >>
+ - run:
+ name: Run integration tests
+ no_output_timeout: << parameters.no_output_timeout >>
+ command: |
+ set -x
+ export PATH=$(echo "$PATH" | sed -e 's|:<< parameters.circleci_home >>/\.go_workspace/bin||g' | sed -e 's|:/usr/local/go/bin||g')
+ export KMD_NOUSB=True
+ export GOPATH="<< parameters.circleci_home >>/go"
+ export PATH="${PATH}:${GOPATH}/bin"
+ export ALGORAND_DEADLOCK=enable
+ export BUILD_TYPE=integration
+ GOLANG_VERSION=$(./scripts/get_golang_version.sh)
+ eval "$(~/gimme "${GOLANG_VERSION}")"
+ scripts/configure_dev.sh
+ scripts/buildtools/install_buildtools.sh -o "gotest.tools/gotestsum"
+ export ALGOTEST=1
+ export SHORTTEST=<< parameters.short_test_flag >>
+ export TEST_RESULTS=/tmp/results/<< parameters.result_subdir >>
+ export PARTITION_TOTAL=$CIRCLE_NODE_TOTAL
+ export PARTITION_ID=$CIRCLE_NODE_INDEX
+ test/scripts/run_integration_tests.sh
+ - store_artifacts:
+ path: /tmp/results
+ destination: test-results
+ - store_test_results:
+ path: /tmp/results
+
+jobs:
+ codegen_verification:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: medium
+ steps:
+ - checkout
+ - prepare_go
+ - run: |
+ export PATH=$(echo "$PATH" | sed -e 's|:/home/circleci/\.go_workspace/bin||g' | sed -e 's|:/usr/local/go/bin||g')
+ export GOPATH="/home/circleci/go"
+ scripts/travis/codegen_verification.sh
+
+ amd64_build:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: medium
+ steps:
+ - checkout
+ - prepare_go
+ - generic_build
+
+ amd64_test:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: medium
+ parallelism: 4
+ steps:
+ - prepare_go
+ - generic_buildtest:
+ result_subdir: amd64-short
+ short_test_flag: "-short"
+ - upload_coverage
+
+ amd64_test_nightly:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: medium
+ parallelism: 4
+ steps:
+ - prepare_go
+ - generic_buildtest:
+ result_subdir: amd64-nightly
+ no_output_timeout: 45m
+ - upload_coverage
+
+ amd64_integration:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: medium
+ parallelism: 4
+ environment:
+ SKIP_E2E_SUBS: "true"
+ steps:
+ - prepare_go
+ - generic_integration:
+ result_subdir: amd64-integration
+ short_test_flag: "-short"
+
+ amd64_integration_nightly:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: medium
+ parallelism: 4
+ environment:
+ SKIP_E2E_SUBS: "true"
+ steps:
+ - prepare_go
+ - generic_integration:
+ result_subdir: amd64-integrationnightly
+ no_output_timeout: 45m
+
+ amd64_e2e_subs:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: large
+ environment:
+ E2E_SUBS_ONLY: "true"
+ steps:
+ - prepare_go
+ - generic_integration:
+ result_subdir: amd64-e2e_subs
+ short_test_flag: "-short"
+
+ amd64_e2e_subs_nightly:
+ machine:
+ image: ubuntu-2004:202104-01
+ resource_class: large
+ environment:
+ E2E_SUBS_ONLY: "true"
+ steps:
+ - prepare_go
+ - generic_integration:
+ result_subdir: amd64-e2e_subs_nightly
+ no_output_timeout: 45m
+
+ arm64_build:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.medium
+ steps:
+ - checkout
+ - prepare_go
+ - generic_build
+
+ arm64_test:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.medium
+ parallelism: 4
+ steps:
+ - checkout
+ - prepare_go
+ - generic_buildtest:
+ result_subdir: arm64-short
+ short_test_flag: "-short"
+ - upload_coverage
+
+ arm64_test_nightly:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.medium
+ parallelism: 4
+ steps:
+ - checkout
+ - prepare_go
+ - generic_buildtest:
+ result_subdir: arm64-nightly
+ no_output_timeout: 45m
+ - upload_coverage
+
+ arm64_integration:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.medium
+ parallelism: 4
+ environment:
+ SKIP_E2E_SUBS: "true"
+ steps:
+ - checkout
+ - prepare_go
+ - generic_integration:
+ result_subdir: arm64-integration
+ short_test_flag: "-short"
+
+ arm64_integration_nightly:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.medium
+ parallelism: 4
+ environment:
+ SKIP_E2E_SUBS: "true"
+ steps:
+ - checkout
+ - prepare_go
+ - generic_integration:
+ result_subdir: arm64-integration-nightly
+ no_output_timeout: 45m
+
+ arm64_e2e_subs:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.large
+ environment:
+ E2E_SUBS_ONLY: "true"
+ steps:
+ - checkout
+ - prepare_go
+ - generic_integration:
+ result_subdir: arm64-e2e_subs
+ short_test_flag: "-short"
+
+ arm64_e2e_subs_nightly:
+ machine:
+ image: ubuntu-2004:202101-01
+ resource_class: arm.large
+ environment:
+ E2E_SUBS_ONLY: "true"
+ steps:
+ - checkout
+ - prepare_go
+ - generic_integration:
+ result_subdir: arm64-e2e_subs-nightly
+ no_output_timeout: 45m
+
+ mac_amd64_build:
+ macos:
+ xcode: 12.0.1
+ resource_class: medium
+ environment:
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - checkout
+ - prepare_go
+ - generic_build:
+ circleci_home: /Users/distiller
+
+ mac_amd64_test:
+ macos:
+ xcode: 12.0.1
+ resource_class: medium
+ environment:
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ parallelism: 4
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - prepare_go
+ - generic_buildtest:
+ result_subdir: mac-amd64-short
+ circleci_home: /Users/distiller
+ short_test_flag: "-short"
+ - upload_coverage
+
+ mac_amd64_test_nightly:
+ macos:
+ xcode: 12.0.1
+ resource_class: medium
+ environment:
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ parallelism: 4
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - prepare_go
+ - generic_buildtest:
+ result_subdir: mac-amd64-short
+ circleci_home: /Users/distiller
+ no_output_timeout: 45m
+ - upload_coverage
+
+ mac_amd64_integration:
+ macos:
+ xcode: 12.0.1
+ resource_class: medium
+ parallelism: 4
+ environment:
+ SKIP_E2E_SUBS: "true"
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - prepare_go
+ - generic_integration:
+ result_subdir: mac-amd64-integration
+ circleci_home: /Users/distiller
+ short_test_flag: "-short"
+
+ mac_amd64_integration_nightly:
+ macos:
+ xcode: 12.0.1
+ resource_class: medium
+ parallelism: 4
+ environment:
+ SKIP_E2E_SUBS: "true"
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - prepare_go
+ - generic_integration:
+ result_subdir: mac-amd64-integration-nightly
+ circleci_home: /Users/distiller
+ no_output_timeout: 45m
+
+ mac_amd64_e2e_subs:
+ macos:
+ xcode: 12.0.1
+ resource_class: large
+ environment:
+ E2E_SUBS_ONLY: "true"
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - prepare_go
+ - generic_integration:
+ result_subdir: mac-amd64-e2e_subs
+ circleci_home: /Users/distiller
+ short_test_flag: "-short"
+
+ mac_amd64_e2e_subs_nightly:
+ macos:
+ xcode: 12.0.1
+ resource_class: large
+ environment:
+ E2E_SUBS_ONLY: "true"
+ HOMEBREW_NO_AUTO_UPDATE: "true"
+ steps:
+ #- run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
+ - prepare_go
+ - generic_integration:
+ result_subdir: mac-amd64-e2e_subs-nightly
+ circleci_home: /Users/distiller
+ no_output_timeout: 45m
+ windows_x64_build:
+ executor:
+ name: win/default
+ size: large
+ steps:
+ - checkout
+ - prepare_windows
+ - run:
+ no_output_timeout: 45m
+ command: |
+ #export PATH=$(echo "$PATH" | sed -e 's|:/home/circleci/\.go_workspace/bin||g' | sed -e 's|:/usr/local/go/bin||g')
+ export GOPATH="/home/circleci/go"
+ export ALGORAND_DEADLOCK=enable
+ export NO_GIMME=True
+ export PATH=/mingw64/bin:/C/tools/msys64/mingw64/bin:/usr/bin:$PATH
+ export MAKE=mingw32-make
+ $msys2 scripts/travis/build_test.sh
+ shell: bash.exe
diff --git a/.github/ISSUE_TEMPLATE/algorand-engineering-team-issue-template.md b/.github/ISSUE_TEMPLATE/algorand-engineering-team-issue-template.md
deleted file mode 100644
index 246ad6018..000000000
--- a/.github/ISSUE_TEMPLATE/algorand-engineering-team-issue-template.md
+++ /dev/null
@@ -1,21 +0,0 @@
----
-name: Algorand Engineering Team Issue Template
-about: This is the template that Algorand internal team members use in conjunction
- with their task management process. Feel free to use if you're an external contributor.
-title: ''
-labels: ''
-assignees: ''
-
----
-
-## Problem
-<!-- What is the problem that we’re trying to solve? -->
-
-## Solution
-<!-- Do you have a potential/suggested solution? Document more than one if possible. -->
-
-## Dependencies
-<!-- Does the solution have any team or design dependencies? -->
-
-## Urgency
-<!-- What is the urgency here and why? -->
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index b3df74a87..7a16b83cb 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -4,17 +4,20 @@ about: Suggestions for how we can improve the algorand platform.
title: ''
labels: new-feature-request
assignees: ''
-
---
-## Is your feature request related to a problem? Please describe.
+## Problem
+
+<!-- What is the problem that we’re trying to solve? -->
+
+## Solution
-<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
+<!-- Do you have a potential/suggested solution? Document more than one if possible. -->
-## Describe the solution you'd like.
+## Dependencies
-<!-- A clear and concise description of what you want to happen. -->
+<!-- Does the solution have any team or design dependencies? -->
-## Additional context.
+## Urgency
-<!-- Add any other context or screenshots about the feature request here. -->
+<!-- What is the urgency here and why? -->
diff --git a/.golangci.yml b/.golangci.yml
index 46e7b8b73..2e2fbe1a0 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,24 +1,30 @@
run:
timeout: 5m
- tests: false
+ tests: true
linters:
enable:
- golint
- misspell
- govet
+ - ineffassign
+ - partitiontest
disable:
- deadcode
- errcheck
- gosimple
- - ineffassign
- staticcheck
- structcheck
- unused
- varcheck
linters-settings:
+ custom:
+ partitiontest:
+ path: cmd/partitiontest_linter/plugin.so
+ description: This custom linter checks files that end in '_test.go', specifically functions that start with 'Test' and have testing argument, for a line 'partitiontest.ParitionTest(<testing arg>)'
+ original-url: github.com/algorand/go-algorand/cmd/partitiontest_linter
# govet:
# check-shadowing: true
@@ -26,6 +32,12 @@ issues:
# don't use default exclude rules listed in `golangci-lint run --help`
exclude-use-default: false
+ # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
+ max-issues-per-linter: 0
+
+ # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
+ max-same-issues: 0
+
exclude-rules:
# ignore govet false positive fixed in https://github.com/golang/go/issues/45043
- linters:
diff --git a/.travis.yml b/.travis.yml
index c71c66279..83a9d5717 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -217,8 +217,8 @@ before_cache:
esac
docker save -o $HOME/docker_cache/images.tar $(docker images -a -q)
-after_success:
- - scripts/travis/upload_coverage.sh || true
+#after_success:
+# - scripts/travis/upload_coverage.sh || true
addons:
apt:
diff --git a/Makefile b/Makefile
index d8e82226c..5ba6defbd 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ BUILDBRANCH := $(shell ./scripts/compute_branch.sh)
CHANNEL ?= $(shell ./scripts/compute_branch_channel.sh $(BUILDBRANCH))
DEFAULTNETWORK ?= $(shell ./scripts/compute_branch_network.sh $(BUILDBRANCH))
DEFAULT_DEADLOCK ?= $(shell ./scripts/compute_branch_deadlock_default.sh $(BUILDBRANCH))
+export GOCACHE=$(SRCPATH)/tmp/go-cache
GOTAGSLIST := sqlite_unlock_notify sqlite_omit_load_extension
@@ -75,7 +76,7 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \
UNIT_TEST_SOURCES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | grep -v /go-algorand/test/ ))
ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd daemon/algod/api; go list ./... ))
-MSGP_GENERATE := ./protocol ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert
+MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert
default: build
@@ -203,9 +204,9 @@ build: buildsrc
# to cache binaries from time to time on empty NFS
# dirs
buildsrc: check-go-version crypto/libs/$(OS_TYPE)/$(ARCH)/lib/libsodium.a node_exporter NONGO_BIN
- mkdir -p tmp/go-cache && \
- touch tmp/go-cache/file.txt && \
- GOCACHE=$(SRCPATH)/tmp/go-cache go install $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./...
+ mkdir -p "${GOCACHE}" && \
+ touch "${GOCACHE}"/file.txt && \
+ go install $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./...
check-go-version:
./scripts/check_golang_version.sh build
@@ -321,3 +322,8 @@ include ./scripts/release/mule/Makefile.mule
archive:
aws s3 cp tmp/node_pkgs s3://algorand-internal/channel/$(CHANNEL)/$(FULLBUILDNUMBER) --recursive --exclude "*" --include "*$(FULLBUILDNUMBER)*"
+
+build_custom_linters:
+ cd cmd/partitiontest_linter/
+ go build -buildmode=plugin -trimpath plugin/plugin.go
+ cd -
diff --git a/agreement/bundle_test.go b/agreement/bundle_test.go
index dc4141bf2..0ab62dede 100644
--- a/agreement/bundle_test.go
+++ b/agreement/bundle_test.go
@@ -29,10 +29,13 @@ import (
"github.com/algorand/go-algorand/data/committee"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// Test Bundle Creation
func TestBundleCreation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -68,6 +71,8 @@ func TestBundleCreation(t *testing.T) {
// Test Bundle validation with Zero Votes
func TestBundleCreationWithZeroVotes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
//ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
ledger, _, _, _ := readOnlyFixture100()
@@ -105,6 +110,8 @@ func makeBundlePanicWrapper(t *testing.T, message string, proposal proposalValue
//Test Bundle Creation with Validation for duplicate votes from same sender
func TestBundleCreationWithVotesFromSameAddress(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture10()
round := ledger.NextRound()
period := period(0)
@@ -168,6 +175,8 @@ func TestBundleCreationWithVotesFromSameAddress(t *testing.T) {
//Test Bundle Creation with Validation
func TestBundleCreationWithEquivocationVotes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture10()
round := ledger.NextRound()
period := period(0)
@@ -276,6 +285,8 @@ func TestBundleCreationWithEquivocationVotes(t *testing.T) {
//Test Bundle Creation with Validation
func TestBundleCertificationWithEquivocationVotes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture10()
round := ledger.NextRound()
period := period(0)
@@ -349,6 +360,8 @@ func certificatePanicWrapper(t *testing.T, message string, ub unauthenticatedBun
// Test Bundle Creation with Equivocation Votes under Quorum
func TestBundleCreationWithEquivocationVotesUnderQuorum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
diff --git a/agreement/certificate_test.go b/agreement/certificate_test.go
index f789e6e8f..e8b10e810 100644
--- a/agreement/certificate_test.go
+++ b/agreement/certificate_test.go
@@ -28,6 +28,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func makeCertTesting(digest crypto.Digest, votes []vote, equiVotes []equivocationVote) Certificate {
@@ -42,6 +43,8 @@ func verifyBundleAgainstLedger(b unauthenticatedBundle, l Ledger, avv *AsyncVote
}
func TestCertificateGoodCertificateBasic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -68,6 +71,8 @@ func TestCertificateGoodCertificateBasic(t *testing.T) {
}
func TestCertificateGoodCertificateEarlyBreak(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -94,6 +99,8 @@ func TestCertificateGoodCertificateEarlyBreak(t *testing.T) {
}
func TestCertificateFinalCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -120,6 +127,8 @@ func TestCertificateFinalCert(t *testing.T) {
}
func TestCertificateBadCertificateWithFakeDoubleVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -173,6 +182,8 @@ func TestCertificateBadCertificateWithFakeDoubleVote(t *testing.T) {
}
func TestCertificateDifferentBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -202,6 +213,8 @@ func TestCertificateDifferentBlock(t *testing.T) {
}
func TestCertificateNoCertStep(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -224,6 +237,8 @@ func TestCertificateNoCertStep(t *testing.T) {
}
func TestCertificateNotEnoughVotesToCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -256,6 +271,8 @@ func TestCertificateNotEnoughVotesToCert(t *testing.T) {
}
func TestCertificateCertWrongRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -285,6 +302,8 @@ func TestCertificateCertWrongRound(t *testing.T) {
}
func TestCertificateCertWithTooFewVotes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -313,6 +332,8 @@ func TestCertificateCertWithTooFewVotes(t *testing.T) {
}
func TestCertificateDupVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
diff --git a/agreement/cryptoRequestContext_test.go b/agreement/cryptoRequestContext_test.go
index b203128ae..bdd98b8fd 100644
--- a/agreement/cryptoRequestContext_test.go
+++ b/agreement/cryptoRequestContext_test.go
@@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func forEachTagDo(fn func(protocol.Tag)) {
@@ -32,6 +33,8 @@ func forEachTagDo(fn func(protocol.Tag)) {
}
func TestCryptoRequestContextAddCancelRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -65,6 +68,8 @@ func TestCryptoRequestContextAddCancelRound(t *testing.T) {
}
func TestCryptoRequestContextAddCancelPeriod(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -99,6 +104,8 @@ func TestCryptoRequestContextAddCancelPeriod(t *testing.T) {
}
func TestCryptoRequestContextAddCancelProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -123,6 +130,8 @@ func TestCryptoRequestContextAddCancelProposal(t *testing.T) {
}
func TestCryptoRequestContextAddCancelPinnedProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
proposal := cryptoProposalRequest{message: message{Tag: protocol.ProposalPayloadTag}, Round: rnd, Pinned: true}
@@ -146,6 +155,8 @@ func TestCryptoRequestContextAddCancelPinnedProposal(t *testing.T) {
}
func TestCryptoRequestContextAddNoCancelPinnedProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -169,6 +180,8 @@ func TestCryptoRequestContextAddNoCancelPinnedProposal(t *testing.T) {
}
func TestCryptoRequestContextAddNoInterferencePinnedProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -192,6 +205,8 @@ func TestCryptoRequestContextAddNoInterferencePinnedProposal(t *testing.T) {
}
func TestCryptoRequestContextCleanupByRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -239,6 +254,8 @@ func TestCryptoRequestContextCleanupByRound(t *testing.T) {
}
func TestCryptoRequestContextCleanupByRoundPinnedCertify(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
@@ -300,6 +317,8 @@ func TestCryptoRequestContextCleanupByRoundPinnedCertify(t *testing.T) {
}
func TestCryptoRequestContextCleanupByPeriod(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
per := period(10)
@@ -361,6 +380,8 @@ func TestCryptoRequestContextCleanupByPeriod(t *testing.T) {
}
func TestCryptoRequestContextCleanupByPeriodPinned(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pending := makePendingRequestsContext()
rnd := round(10)
diff --git a/agreement/cryptoVerifier_test.go b/agreement/cryptoVerifier_test.go
index 4f9e1edb9..bced9c9f7 100644
--- a/agreement/cryptoVerifier_test.go
+++ b/agreement/cryptoVerifier_test.go
@@ -34,6 +34,7 @@ import (
"github.com/algorand/go-algorand/data/committee"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var _ = fmt.Printf
@@ -136,6 +137,8 @@ func getSelectorCapacity(tag protocol.Tag) int {
}
func TestCryptoVerifierBuffers(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("Test is flaky")
t.Parallel()
diff --git a/agreement/demux_test.go b/agreement/demux_test.go
index a3bd2e286..f099d79f8 100644
--- a/agreement/demux_test.go
+++ b/agreement/demux_test.go
@@ -32,6 +32,7 @@ import (
"github.com/algorand/go-algorand/data/committee"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/timers"
)
@@ -414,6 +415,8 @@ var demuxTestUsecases = []demuxTestUsecase{
}
func TestDemuxNext(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dt := &demuxTester{T: t}
dt.Test()
}
diff --git a/agreement/encoding_test.go b/agreement/encoding_test.go
index 3d514b316..b59c633c8 100644
--- a/agreement/encoding_test.go
+++ b/agreement/encoding_test.go
@@ -22,9 +22,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestEmptyEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var v vote
require.Equal(t, 1, len(protocol.Encode(&v)))
diff --git a/agreement/fuzzer/tests_test.go b/agreement/fuzzer/tests_test.go
index bb0e9a292..f05852e39 100644
--- a/agreement/fuzzer/tests_test.go
+++ b/agreement/fuzzer/tests_test.go
@@ -37,6 +37,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-deadlock"
//"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestMain(m *testing.M) {
@@ -114,6 +115,7 @@ func TestCircularNetworkTopology(t *testing.T) {
nodeCount := nodeCounts[i]
t.Run(fmt.Sprintf("TestCircularNetworkTopology-%d", nodeCount),
func(t *testing.T) {
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
nodes := nodeCount
topologyConfig := TopologyFilterConfig{
NodesConnection: make(map[int][]int),
@@ -430,6 +432,7 @@ func TestFuzzer(t *testing.T) {
require.NoError(t, err)
for testName := range jsonFiles {
t.Run(testName, func(t *testing.T) {
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
jsonFilename := jsonFiles[testName]
jsonBytes, err := ioutil.ReadFile(jsonFilename)
require.NoError(t, err)
@@ -493,6 +496,7 @@ func TestNetworkBandwidth(t *testing.T) {
nodeCount := nodeCounts[i]
t.Run(fmt.Sprintf("TestNetworkBandwidth-%d", nodeCount),
func(t *testing.T) {
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
nodes := nodeCount
topologyConfig := TopologyFilterConfig{
NodesConnection: make(map[int][]int),
@@ -544,7 +548,7 @@ func TestUnstakedNetworkLinearGrowth(t *testing.T) {
if testing.Short() {
t.Skip()
}
-
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
relayCount := 8
stakedNodeCount := 4
deadlock.Opts.Disable = true
@@ -657,7 +661,7 @@ func TestStakedNetworkQuadricGrowth(t *testing.T) {
if testing.Short() {
t.Skip()
}
-
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
relayCount := 1
nodeCount := []int{4, 5, 6, 7, 8, 9, 10}
totalRelayedMessages := []int{}
@@ -768,7 +772,7 @@ func TestRegossipinngElimination(t *testing.T) {
if testing.Short() {
t.Skip()
}
-
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
relayCounts := 8
nodeCount := 20
deadlock.Opts.Disable = true
diff --git a/agreement/gossip/networkFull_test.go b/agreement/gossip/networkFull_test.go
index 54b7899b6..ce49b579e 100644
--- a/agreement/gossip/networkFull_test.go
+++ b/agreement/gossip/networkFull_test.go
@@ -28,12 +28,14 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util"
)
const testNetTimeout = 100 * time.Millisecond
func TestMain(m *testing.M) {
+
logging.Base().SetLevel(logging.Debug)
// increase limit on max allowed number of sockets
err := util.RaiseRlimit(500)
@@ -124,6 +126,8 @@ func shutdownNetwork(nets []*networkImpl, counters []*messageCounter) {
}
func TestNetworkImplFullStackLong(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -132,6 +136,8 @@ func TestNetworkImplFullStackLong(t *testing.T) {
}
func TestNetworkImplFullStackQuick(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if !testing.Short() {
t.Skip()
}
diff --git a/agreement/gossip/network_test.go b/agreement/gossip/network_test.go
index ed6f7ca24..3bbf744ca 100644
--- a/agreement/gossip/network_test.go
+++ b/agreement/gossip/network_test.go
@@ -32,6 +32,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type sentMessage struct {
@@ -338,6 +339,8 @@ func spinNetworkImpl(domain *whiteholeDomain) (whiteholeNet *whiteholeNetwork, c
}
func TestNetworkImpl(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
domain := &whiteholeDomain{
diff --git a/agreement/msgp_gen_test.go b/agreement/msgp_gen_test.go
index 84306b282..4bfe9d028 100644
--- a/agreement/msgp_gen_test.go
+++ b/agreement/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalCertificate(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Certificate{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalCertificate(b *testing.B) {
}
func TestMarshalUnmarshalbundle(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := bundle{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalbundle(b *testing.B) {
}
func TestMarshalUnmarshalequivocationVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := equivocationVote{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalequivocationVote(b *testing.B) {
}
func TestMarshalUnmarshalequivocationVoteAuthenticator(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := equivocationVoteAuthenticator{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -248,6 +253,7 @@ func BenchmarkUnmarshalequivocationVoteAuthenticator(b *testing.B) {
}
func TestMarshalUnmarshalproposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := proposal{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -307,6 +313,7 @@ func BenchmarkUnmarshalproposal(b *testing.B) {
}
func TestMarshalUnmarshalproposalValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := proposalValue{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -366,6 +373,7 @@ func BenchmarkUnmarshalproposalValue(b *testing.B) {
}
func TestMarshalUnmarshalproposerSeed(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := proposerSeed{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -425,6 +433,7 @@ func BenchmarkUnmarshalproposerSeed(b *testing.B) {
}
func TestMarshalUnmarshalrawVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := rawVote{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -484,6 +493,7 @@ func BenchmarkUnmarshalrawVote(b *testing.B) {
}
func TestMarshalUnmarshalseedInput(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := seedInput{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -543,6 +553,7 @@ func BenchmarkUnmarshalseedInput(b *testing.B) {
}
func TestMarshalUnmarshalselector(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := selector{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -602,6 +613,7 @@ func BenchmarkUnmarshalselector(b *testing.B) {
}
func TestMarshalUnmarshaltransmittedPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := transmittedPayload{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -661,6 +673,7 @@ func BenchmarkUnmarshaltransmittedPayload(b *testing.B) {
}
func TestMarshalUnmarshalunauthenticatedBundle(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := unauthenticatedBundle{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -720,6 +733,7 @@ func BenchmarkUnmarshalunauthenticatedBundle(b *testing.B) {
}
func TestMarshalUnmarshalunauthenticatedEquivocationVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := unauthenticatedEquivocationVote{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -779,6 +793,7 @@ func BenchmarkUnmarshalunauthenticatedEquivocationVote(b *testing.B) {
}
func TestMarshalUnmarshalunauthenticatedProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := unauthenticatedProposal{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -838,6 +853,7 @@ func BenchmarkUnmarshalunauthenticatedProposal(b *testing.B) {
}
func TestMarshalUnmarshalunauthenticatedVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := unauthenticatedVote{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -897,6 +913,7 @@ func BenchmarkUnmarshalunauthenticatedVote(b *testing.B) {
}
func TestMarshalUnmarshalvote(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := vote{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -956,6 +973,7 @@ func BenchmarkUnmarshalvote(b *testing.B) {
}
func TestMarshalUnmarshalvoteAuthenticator(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := voteAuthenticator{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/agreement/persistence_test.go b/agreement/persistence_test.go
index 1eb9ac59c..5c1bfda60 100644
--- a/agreement/persistence_test.go
+++ b/agreement/persistence_test.go
@@ -26,11 +26,14 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
"github.com/algorand/go-algorand/util/timers"
)
func TestAgreementSerialization(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// todo : we need to deserialize some more meaningfull state.
clock := timers.MakeMonotonicClock(time.Date(2015, 1, 2, 5, 6, 7, 8, time.UTC))
status := player{Round: 350, Step: soft, Deadline: time.Duration(23) * time.Second}
@@ -82,6 +85,8 @@ func BenchmarkAgreementDeserialization(b *testing.B) {
}
func TestAgreementPersistence(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
accessor, err := db.MakeAccessor(t.Name()+"_crash.db", false, true)
require.NoError(t, err)
defer accessor.Close()
diff --git a/agreement/player_permutation_test.go b/agreement/player_permutation_test.go
index 74d1292ef..2b832c63b 100644
--- a/agreement/player_permutation_test.go
+++ b/agreement/player_permutation_test.go
@@ -27,6 +27,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func makeRandomProposalPayload(r round) *proposal {
@@ -744,6 +745,8 @@ func verifyPermutationExpectedActions(t *testing.T, playerN int, eventN int, hel
// Generates a set of player states, router states, and messageEvents and tests all permutations of them
func TestPlayerPermutation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for i := 0; i < 7; i++ {
for j := 0; j < 14; j++ {
_, pMachine, helper := getPlayerPermutation(t, i)
diff --git a/agreement/player_test.go b/agreement/player_test.go
index 1b565e9f9..0719864c7 100644
--- a/agreement/player_test.go
+++ b/agreement/player_test.go
@@ -26,6 +26,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var playerTracer tracer
@@ -425,6 +426,8 @@ func testPlayerSetup() (player, rootRouter, testAccountData, testBlockFactory, L
}
func TestPlayerSynchronous(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, router, accs, f, ledger := testPlayerSetup()
for i := 0; i < 20; i++ {
@@ -433,6 +436,8 @@ func TestPlayerSynchronous(t *testing.T) {
}
func TestPlayerOffsetStart(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, router, accs, f, ledger := testPlayerSetup()
simulateTimeoutExpectAlarm(t, &router, &player)
@@ -451,6 +456,8 @@ func TestPlayerOffsetStart(t *testing.T) {
}
func TestPlayerLateBlockProposalPeriod0(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, router, accs, f, ledger := testPlayerSetup()
proposalVoteEventBatch, proposalPayloadEventBatch, lowestProposal := generateProposalEvents(t, player, accs, f, ledger)
@@ -504,6 +511,8 @@ func setupP(t *testing.T, r round, p period, s step) (plyr *player, pMachine ioA
// ISV = Issue Soft Vote
func TestPlayerISVDoesNotSoftVoteBottom(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// every soft vote is associated with a proposalValue != bottom.
const r = round(209)
const p = period(1)
@@ -528,6 +537,8 @@ func TestPlayerISVDoesNotSoftVoteBottom(t *testing.T) {
}
func TestPlayerISVVoteForStartingValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if we see a next value quorum, and no next bottom quorum, vote for that value regardless
// every soft vote is associated with a proposalValue != bottom.
const r = round(209)
@@ -571,6 +582,8 @@ func TestPlayerISVVoteForStartingValue(t *testing.T) {
}
func TestPlayerISVVoteNoVoteSansProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if we see no proposal, even if we see a next-value bottom quorum, do not issue a soft vote
const r = round(209)
@@ -622,6 +635,8 @@ func TestPlayerISVVoteNoVoteSansProposal(t *testing.T) {
}
func TestPlayerISVVoteForReProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// even if we saw bottom, if we see reproposal, and a next value quorum, vote for it
// why do reproposals need to be associated with next value quorums? (instead of just a next
// bottom quorum) - seems to be important for seed biasing
@@ -709,6 +724,8 @@ func TestPlayerISVVoteForReProposal(t *testing.T) {
}
func TestPlayerISVNoVoteForUnsupportedReProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if there's no next value quorum, don't support the reproposal
const r = round(209)
const p = period(11)
@@ -767,6 +784,8 @@ func TestPlayerISVNoVoteForUnsupportedReProposal(t *testing.T) {
// ICV = Issue Cert Vote
func TestPlayerICVOnSoftThresholdSamePeriod(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// basic cert vote check.
// This also tests cert vote even if freeze timer has not yet fired
const r = round(12)
@@ -839,6 +858,8 @@ func TestPlayerICVOnSoftThresholdSamePeriod(t *testing.T) {
}
func TestPlayerICVOnSoftThresholdPrePayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Check cert voting when soft bundle is received
// before a proposal payload. Should still generate cert vote.
@@ -909,6 +930,8 @@ func TestPlayerICVOnSoftThresholdPrePayload(t *testing.T) {
}
func TestPlayerICVOnSoftThresholdThenPayloadNoProposalVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if there's no proposal vote, a soft threshold should still trigger a cert vote
const r = round(12)
const p = period(1)
@@ -961,6 +984,8 @@ func TestPlayerICVOnSoftThresholdThenPayloadNoProposalVote(t *testing.T) {
}
func TestPlayerICVNoVoteForUncommittableProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(12)
const p = period(1)
pWhite, pM, helper := setupP(t, r, p, soft)
@@ -1016,6 +1041,8 @@ func TestPlayerICVNoVoteForUncommittableProposal(t *testing.T) {
}
func TestPlayerICVPanicOnSoftBottomThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(209)
const p = period(1)
_, pM, helper := setupP(t, r, p, 0)
@@ -1048,6 +1075,8 @@ func TestPlayerICVPanicOnSoftBottomThreshold(t *testing.T) {
// FF = Fast Forwarding
func TestPlayerFFSoftThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// future periods
const r = round(201221)
const p = period(0)
@@ -1086,6 +1115,8 @@ func TestPlayerFFSoftThreshold(t *testing.T) {
}
func TestPlayerFFSoftThresholdWithPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// future periods
// must also cert vote
const r = round(201221)
@@ -1157,6 +1188,8 @@ func TestPlayerFFSoftThresholdWithPayload(t *testing.T) {
}
func TestPlayerFFSoftThresholdLatePayloadCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// should cert vote after fast forwarding due to soft bundle, if we see late payload
const r = round(201221)
const p = period(0)
@@ -1227,6 +1260,8 @@ func TestPlayerFFSoftThresholdLatePayloadCert(t *testing.T) {
}
func TestPlayerFFNextThresholdBottom(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine starting at period 0
const r = round(209)
pWhite, pM, helper := setupP(t, r, period(0), soft)
@@ -1261,6 +1296,8 @@ func TestPlayerFFNextThresholdBottom(t *testing.T) {
}
func TestPlayerFFNextThresholdValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine starting at period 0
const r = round(209)
pWhite, pM, helper := setupP(t, r, period(0), soft)
@@ -1295,6 +1332,8 @@ func TestPlayerFFNextThresholdValue(t *testing.T) {
}
func TestPlayerDoesNotFastForwardOldThresholdEvents(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// thresholds/bundles with p_k < p are useless and should not cause any logic
// (though, in the process of generating the threshold, it should update cached next bundle)
const r = round(209)
@@ -1382,6 +1421,8 @@ func TestPlayerDoesNotFastForwardOldThresholdEvents(t *testing.T) {
// Proposals
// Contract: player should not propose unless it sees valid proof of proposal safety
func TestPlayerProposesBottomBundle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// sanity check that player actually proposes something
// player should create a new proposal
const r = round(209)
@@ -1420,6 +1461,8 @@ func TestPlayerProposesBottomBundle(t *testing.T) {
}
func TestPlayerProposesNewRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// player should create a new proposal on new round
const r = round(209)
const p = period(0)
@@ -1482,6 +1525,8 @@ func TestPlayerProposesNewRound(t *testing.T) {
}
func TestPlayerCertificateThenPayloadEntersNewRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// player should create a new proposal on new round
const r = round(209)
const p = period(0)
@@ -1535,6 +1580,8 @@ func TestPlayerCertificateThenPayloadEntersNewRound(t *testing.T) {
}
func TestPlayerReproposesNextValueBundleWithoutPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Even having not seen the payload, player should still repropose
const r = round(209)
const p = period(11)
@@ -1577,6 +1624,8 @@ func TestPlayerReproposesNextValueBundleWithoutPayload(t *testing.T) {
}
func TestPlayerReproposesNextValueBundleRelaysPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// player should forward the proposal payload, forwad freshest bundle, and broadcast a reproposal vote.
// which comes from the previous period. (has period set to p - 1)
const r = round(209)
@@ -1676,6 +1725,8 @@ func TestPlayerReproposesNextValueBundleRelaysPayload(t *testing.T) {
// Commitment
func TestPlayerCommitsCertThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(20239)
const p = period(1001)
pWhite, pM, helper := setupP(t, r-1, p, soft)
@@ -1742,6 +1793,8 @@ const testPartitionPeriod = 3
var testPartitionStep = partitionStep
func TestPlayerRePropagatesFreshestBundle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// let's just fire a bunch of timeouts
const r = round(20239)
const p = period(2)
@@ -1803,6 +1856,8 @@ func TestPlayerRePropagatesFreshestBundle(t *testing.T) {
}
func TestPlayerPropagatesProposalPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if a player receives a payload from the network, it should relay it.
const r = round(209)
_, pM, helper := setupP(t, r, 0, soft)
@@ -1838,6 +1893,8 @@ func TestPlayerPropagatesProposalPayload(t *testing.T) {
}
func TestPlayerPropagatesOwnProposalPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if a player receives a PayloadVerified event with its own payload, it should relay it.
const r = round(209)
_, pM, helper := setupP(t, r, 0, soft)
@@ -1873,6 +1930,8 @@ func TestPlayerPropagatesOwnProposalPayload(t *testing.T) {
}
func TestPlayerPropagatesProposalPayloadFutureRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if a player receives a proposal payload for a future round, it should still
// propagate it at some point.
const r = round(209)
@@ -1917,6 +1976,8 @@ func TestPlayerPropagatesProposalPayloadFutureRound(t *testing.T) {
}
func TestPlayerRePropagatesProposalPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if player broadcasts a non-bottom freshest bundle during recovery/resynch, broadcast the
// associated proposal payload. note this is distinct from relaying the payload
// on seeing a reproposal/proposal vote.
@@ -2103,6 +2164,8 @@ func TestPlayerRePropagatesProposalPayload(t *testing.T) {
}
func TestPlayerPropagatesProposalVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(209)
_, pM, helper := setupP(t, r, 0, soft)
_, pV := helper.MakeRandomProposalPayload(t, r)
@@ -2125,6 +2188,8 @@ func TestPlayerPropagatesProposalVote(t *testing.T) {
}
func TestPlayerPropagatesSoftVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(209)
_, pM, helper := setupP(t, r, 0, soft)
_, pV := helper.MakeRandomProposalPayload(t, r)
@@ -2147,6 +2212,8 @@ func TestPlayerPropagatesSoftVote(t *testing.T) {
}
func TestPlayerPropagatesCertVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(209)
_, pM, helper := setupP(t, r, 0, cert)
_, pV := helper.MakeRandomProposalPayload(t, r)
@@ -2171,6 +2238,8 @@ func TestPlayerPropagatesCertVote(t *testing.T) {
// Malformed Messages
// check both proposals, proposal payloads, and votes, bundles
func TestPlayerDisconnectsFromMalformedProposalVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, helper := setupP(t, r, p, cert)
@@ -2208,6 +2277,8 @@ func TestPlayerDisconnectsFromMalformedProposalVote(t *testing.T) {
}
func TestPlayerIgnoresMalformedPayload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, _ := setupP(t, r, p, cert)
@@ -2245,6 +2316,8 @@ func TestPlayerIgnoresMalformedPayload(t *testing.T) {
}
func TestPlayerDisconnectsFromMalformedVotes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, helper := setupP(t, r, p, cert)
@@ -2283,6 +2356,8 @@ func TestPlayerDisconnectsFromMalformedVotes(t *testing.T) {
}
func TestPlayerDisconnectsFromMalformedBundles(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, _ := setupP(t, r, p, cert)
@@ -2321,6 +2396,8 @@ func TestPlayerDisconnectsFromMalformedBundles(t *testing.T) {
// Helper Sanity Checks
func TestPlayerRequestsVoteVerification(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, helper := setupP(t, r, p, cert)
@@ -2342,6 +2419,8 @@ func TestPlayerRequestsVoteVerification(t *testing.T) {
}
func TestPlayerRequestsProposalVoteVerification(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(1)
const p = period(0)
_, pM, helper := setupP(t, r, p, cert)
@@ -2363,6 +2442,8 @@ func TestPlayerRequestsProposalVoteVerification(t *testing.T) {
}
func TestPlayerRequestsBundleVerification(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, _ := setupP(t, r, p, cert)
@@ -2386,6 +2467,8 @@ func TestPlayerRequestsBundleVerification(t *testing.T) {
// Payload Pipelining
func TestPlayerRequestsPayloadVerification(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
_, pM, helper := setupP(t, r, p, cert)
@@ -2421,6 +2504,8 @@ func TestPlayerRequestsPayloadVerification(t *testing.T) {
}
func TestPlayerRequestsPipelinedPayloadVerification(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(201221)
const p = period(0)
pWhite, pM, helper := setupP(t, r, p, cert)
@@ -2514,6 +2599,8 @@ func TestPlayerRequestsPipelinedPayloadVerification(t *testing.T) {
// Round pipelining
func TestPlayerHandlesPipelinedThresholds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// make sure we stage a pipelined soft threshold after entering new round
const r = round(20)
const p = period(0)
@@ -2626,6 +2713,8 @@ func TestPlayerHandlesPipelinedThresholds(t *testing.T) {
}
func TestPlayerRegression_EnsuresCertThreshFromOldPeriod_8ba23942(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// should not ignore cert thresholds from previous period in same round, if it
// was saved as freshest threshold
const r = round(20)
@@ -2700,6 +2789,8 @@ func TestPlayerRegression_EnsuresCertThreshFromOldPeriod_8ba23942(t *testing.T)
}
func TestPlayer_RejectsCertThresholdFromPreviousRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(20)
const p = period(0)
pWhite, pM, helper := setupP(t, r, p, cert)
@@ -2733,6 +2824,8 @@ func TestPlayer_RejectsCertThresholdFromPreviousRound(t *testing.T) {
}
func TestPlayer_CommitsCertThresholdWithoutPreStaging(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if player has pinned a block, then sees a cert threshold, it should commit
const r = round(20)
const p = period(0)
@@ -2807,6 +2900,8 @@ func TestPlayer_CommitsCertThresholdWithoutPreStaging(t *testing.T) {
}
func TestPlayer_CertThresholdDoesNotBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// check that ledger gets a hint to stage digest
const r = round(20)
const p = period(0)
@@ -2841,6 +2936,8 @@ func TestPlayer_CertThresholdDoesNotBlock(t *testing.T) {
}
func TestPlayer_CertThresholdDoesNotBlockFuturePeriod(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// check that ledger gets a hint to stage digest
const r = round(20)
const p = period(0)
@@ -2875,6 +2972,8 @@ func TestPlayer_CertThresholdDoesNotBlockFuturePeriod(t *testing.T) {
}
func TestPlayer_CertThresholdFastForwards(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(20)
const p = period(0)
pWhite, pM, helper := setupP(t, r, p, cert)
@@ -2913,6 +3012,8 @@ func TestPlayer_CertThresholdFastForwards(t *testing.T) {
}
func TestPlayer_CertThresholdCommitsFuturePeriodIfAlreadyHasBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(20)
const p = period(0)
pWhite, pM, helper := setupP(t, r, p, cert)
@@ -2976,6 +3077,8 @@ func TestPlayer_CertThresholdCommitsFuturePeriodIfAlreadyHasBlock(t *testing.T)
}
func TestPlayer_PayloadAfterCertThresholdCommits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = round(20)
const p = period(0)
pWhite, pM, helper := setupP(t, r, p, cert)
@@ -3032,6 +3135,8 @@ func TestPlayer_PayloadAfterCertThresholdCommits(t *testing.T) {
}
func TestPlayerAlwaysResynchsPinnedValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// a white box test that checks the pinned value is relayed even it is not staged in the period corresponding to the freshest bundle
const r = round(209)
const p = period(12)
diff --git a/agreement/proposal.go b/agreement/proposal.go
index cc41e1f3f..e823ce0ce 100644
--- a/agreement/proposal.go
+++ b/agreement/proposal.go
@@ -197,13 +197,13 @@ func verifyNewSeed(p unauthenticatedProposal, ledger LedgerReader) error {
if value.OriginalPeriod == 0 {
verifier := proposerRecord.SelectionID
- ok, vrfOut := verifier.Verify(p.SeedProof, prevSeed)
+ ok, _ := verifier.Verify(p.SeedProof, prevSeed) // ignoring VrfOutput returned by Verify
if !ok {
return fmt.Errorf("payload seed proof malformed (%v, %v)", prevSeed, p.SeedProof)
}
// TODO remove the following Hash() call,
// redundant with the Verify() call above.
- vrfOut, ok = p.SeedProof.Hash()
+ vrfOut, ok := p.SeedProof.Hash()
if !ok {
// If proof2hash fails on a proof we produced with VRF Prove, this indicates our VRF code has a dangerous bug.
// Panicking is the only safe thing to do.
diff --git a/agreement/proposalManager_test.go b/agreement/proposalManager_test.go
index 6c97330b5..24bdb9d0d 100644
--- a/agreement/proposalManager_test.go
+++ b/agreement/proposalManager_test.go
@@ -19,6 +19,7 @@ package agreement
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -42,6 +43,8 @@ func setupManager(t *testing.T, r round) (pWhite *proposalManager, pMachine ioAu
}
func TestProposalManagerThresholdSoftFastForward(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// sanity check that manager tells underlings to fast forward new period
const p = 1
const r = 10
@@ -69,6 +72,8 @@ func TestProposalManagerThresholdSoftFastForward(t *testing.T) {
}
func TestProposalManagerThresholdSoftStage(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// sanity check that manager tells underlings to deal with soft threshold
const p = 1
const r = 10
@@ -105,6 +110,8 @@ func TestProposalManagerThresholdSoftStage(t *testing.T) {
}
func TestProposalManagerThresholdCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const p = 10
const r = 1
_, pM, helper := setupManager(t, r)
@@ -140,6 +147,8 @@ func TestProposalManagerThresholdCert(t *testing.T) {
}
func TestProposalManagerThresholdNext(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// check that manager tells the Tracker to increase period +1
const p = 10
const r = 1
@@ -167,6 +176,8 @@ func TestProposalManagerThresholdNext(t *testing.T) {
}
func TestProposalManagerResetsRoundInterruption(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// check that manager tells Store to increase round + 1
const p = 10
const r = 1
@@ -183,6 +194,8 @@ func TestProposalManagerResetsRoundInterruption(t *testing.T) {
}
func TestProposalManagerRejectsUnknownEvent(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// check that manager discards unknown events.
_, pM, _ := setupManager(t, 0)
@@ -197,6 +210,8 @@ func TestProposalManagerRejectsUnknownEvent(t *testing.T) {
}
func TestProposalFreshAdjacentPeriods(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// votes from periods that are non-adjacent to current period are not fresh
// unfortunately, this is more of an end-to-end test as the proposeTracker will also filter
const r = 100
@@ -314,6 +329,8 @@ func TestProposalFreshAdjacentPeriods(t *testing.T) {
}
func TestProposalFreshAdjacentPeriodsVerified(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// verbatim copy of above test case, but with verified votes
// votes from periods that are non-adjacent to current period are not fresh
// unfortunately, this is more of an end-to-end test as the proposeTracker will also filter
@@ -439,6 +456,8 @@ func TestProposalFreshAdjacentPeriodsVerified(t *testing.T) {
}
func TestProposalManagerCancelledVoteFiltered(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const r = 100000
const p = 2
const s = cert
diff --git a/agreement/proposalStore_test.go b/agreement/proposalStore_test.go
index 10c388b87..93f2d15b4 100644
--- a/agreement/proposalStore_test.go
+++ b/agreement/proposalStore_test.go
@@ -28,6 +28,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var proposalStoreTracer tracer
@@ -37,6 +38,8 @@ func init() {
}
func TestProposalStoreCreation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, router, accounts, factory, ledger := testSetup(0)
proposalVoteEventBatch, _, _ := createProposalEvents(t, player, accounts, factory, ledger)
@@ -45,6 +48,8 @@ func TestProposalStoreCreation(t *testing.T) {
}
func TestBlockAssemblerPipeline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
Pipeline unauthenticatedProposal
Filled bool
@@ -113,6 +118,8 @@ func TestBlockAssemblerPipeline(t *testing.T) {
}
func TestBlockAssemblerBind(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
Pipeline unauthenticatedProposal
Filled bool
@@ -179,6 +186,8 @@ func TestBlockAssemblerBind(t *testing.T) {
}
func TestBlockAssemblerAuthenticator(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
Pipeline unauthenticatedProposal
Filled bool
@@ -243,6 +252,8 @@ func TestBlockAssemblerAuthenticator(t *testing.T) {
}
func TestBlockAssemblerTrim(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
Pipeline unauthenticatedProposal
Filled bool
@@ -325,6 +336,7 @@ func TestBlockAssemblerTrim(t *testing.T) {
}
func TestProposalStoreT(t *testing.T) {
+ partitiontest.PartitionTest(t)
player, _, accounts, factory, ledger := testSetup(0)
@@ -392,6 +404,8 @@ func TestProposalStoreT(t *testing.T) {
}
func TestProposalStoreUnderlying(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
Relevant map[period]proposalValue
Pinned proposalValue
@@ -458,6 +472,8 @@ func TestProposalStoreUnderlying(t *testing.T) {
}
func TestProposalStoreHandle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, router, accounts, factory, ledger := testPlayerSetup()
proposalVoteEventBatch, proposalPayloadEventBatch, _ := generateProposalEvents(t, player, accounts, factory, ledger)
@@ -642,6 +658,8 @@ func TestProposalStoreHandle(t *testing.T) {
}
func TestProposalStoreGetPinnedValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// create proposal Store
player, router, accounts, factory, ledger := testPlayerSetup()
testBlockFactory, err := factory.AssembleBlock(player.Round, time.Now().Add(time.Minute))
@@ -694,6 +712,8 @@ func TestProposalStoreGetPinnedValue(t *testing.T) {
}
func TestProposalStoreRegressionBlockRedeliveryBug_b29ea57(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var msgV1, msgV2, msgP1, msgP2 message
var rv rawVote
var propVal proposalValue
@@ -803,6 +823,8 @@ func TestProposalStoreRegressionBlockRedeliveryBug_b29ea57(t *testing.T) {
}
func TestProposalStoreRegressionWrongPipelinePeriodBug_39387501(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var msgV1, msgV2, msgP1, msgP2 message
var rv rawVote
var propVal proposalValue
diff --git a/agreement/proposalTracker_test.go b/agreement/proposalTracker_test.go
index c2511c328..7777ed14b 100644
--- a/agreement/proposalTracker_test.go
+++ b/agreement/proposalTracker_test.go
@@ -21,6 +21,7 @@ import (
"sort"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -51,6 +52,8 @@ func sortedVoteGen(t *testing.T) (votes []vote) {
}
func TestProposalTrackerProposalSeeker(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
votes := sortedVoteGen(t)
for len(votes) < 4 {
votes = sortedVoteGen(t)
@@ -324,6 +327,8 @@ func setupProposalTrackerTests(t *testing.T) (votes []vote) {
}
func TestProposalTrackerBasic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
votes := setupProposalTrackerTests(t)
for len(votes) <= 3 {
votes = setupProposalTrackerTests(t)
diff --git a/agreement/proposal_test.go b/agreement/proposal_test.go
index 94f3204ef..49481ae84 100644
--- a/agreement/proposal_test.go
+++ b/agreement/proposal_test.go
@@ -28,6 +28,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func testSetup(periodCount uint64) (player, rootRouter, testAccountData, testBlockFactory, Ledger) {
@@ -107,6 +108,8 @@ func createProposalEvents(t *testing.T, player player, accs testAccountData, f t
}
func TestProposalCreation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, router, accounts, factory, ledger := testSetup(0)
proposalVoteEventBatch, _, _ := createProposalEvents(t, player, accounts, factory, ledger)
@@ -115,6 +118,8 @@ func TestProposalCreation(t *testing.T) {
}
func TestProposalFunctions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, _, accs, factory, ledger := testSetup(0)
round := player.Round
period := player.Period
@@ -152,6 +157,8 @@ func TestProposalFunctions(t *testing.T) {
}
func TestProposalUnauthenticated(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
player, _, accounts, factory, ledger := testSetup(0)
round := player.Round
diff --git a/agreement/pseudonode_test.go b/agreement/pseudonode_test.go
index ca6b11c42..72f1a427c 100644
--- a/agreement/pseudonode_test.go
+++ b/agreement/pseudonode_test.go
@@ -29,6 +29,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// The serializedPseudonode is the trivial implementation for the pseudonode interface
@@ -132,6 +133,8 @@ func compareEventChannels(t *testing.T, ch1, ch2 <-chan externalEvent) bool {
}
func TestPseudonode(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// generate a nice, fixed hash.
@@ -388,6 +391,8 @@ func (k *KeyManagerProxy) VotingKeys(votingRound, balanceRound basics.Round) []a
}
func TestPseudonodeLoadingOfParticipationKeys(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// generate a nice, fixed hash.
diff --git a/agreement/service_test.go b/agreement/service_test.go
index d698ef93e..b0469237f 100644
--- a/agreement/service_test.go
+++ b/agreement/service_test.go
@@ -39,6 +39,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
"github.com/algorand/go-algorand/util/timers"
)
@@ -908,6 +909,8 @@ func simulateAgreementWithLedgerFactory(t *testing.T, numNodes int, numRounds in
}
func TestAgreementSynchronous1(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if testing.Short() {
// t.Skip("Skipping agreement integration test")
// }
@@ -916,6 +919,8 @@ func TestAgreementSynchronous1(t *testing.T) {
}
func TestAgreementSynchronous2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if testing.Short() {
// t.Skip("Skipping agreement integration test")
// }
@@ -924,6 +929,8 @@ func TestAgreementSynchronous2(t *testing.T) {
}
func TestAgreementSynchronous3(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// if testing.Short() {
// t.Skip("Skipping agreement integration test")
// }
@@ -932,6 +939,8 @@ func TestAgreementSynchronous3(t *testing.T) {
}
func TestAgreementSynchronous4(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip("Skipping agreement integration test")
}
@@ -940,6 +949,8 @@ func TestAgreementSynchronous4(t *testing.T) {
}
func TestAgreementSynchronous5(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip("Skipping agreement integration test")
}
@@ -948,6 +959,7 @@ func TestAgreementSynchronous5(t *testing.T) {
}
func TestAgreementSynchronous10(t *testing.T) {
+ partitiontest.PartitionTest(t)
t.Skip("Skipping flaky agreement integration test")
if testing.Short() {
t.Skip("Skipping agreement integration test")
@@ -957,6 +969,8 @@ func TestAgreementSynchronous10(t *testing.T) {
}
func TestAgreementSynchronous5_50(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip("Skipping agreement integration test")
}
@@ -965,6 +979,8 @@ func TestAgreementSynchronous5_50(t *testing.T) {
}
func TestAgreementSynchronousFuture1(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
//if testing.Short() {
// t.Skip("Skipping agreement integration test")
//}
@@ -976,6 +992,8 @@ func TestAgreementSynchronousFuture1(t *testing.T) {
}
func TestAgreementSynchronousFuture5(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip("Skipping agreement integration test")
}
@@ -987,6 +1005,8 @@ func TestAgreementSynchronousFuture5(t *testing.T) {
}
func TestAgreementSynchronousFutureUpgrade(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip("Skipping agreement integration test")
}
@@ -1001,6 +1021,8 @@ func TestAgreementSynchronousFutureUpgrade(t *testing.T) {
}
func TestAgreementFastRecoveryDownEarly(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1057,6 +1079,8 @@ func TestAgreementFastRecoveryDownEarly(t *testing.T) {
}
func TestAgreementFastRecoveryDownMiss(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1136,6 +1160,8 @@ func TestAgreementFastRecoveryDownMiss(t *testing.T) {
}
func TestAgreementFastRecoveryLate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1247,6 +1273,8 @@ func TestAgreementFastRecoveryLate(t *testing.T) {
}
func TestAgreementFastRecoveryRedo(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1399,6 +1427,8 @@ func TestAgreementFastRecoveryRedo(t *testing.T) {
}
func TestAgreementBlockReplayBug_b29ea57(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 2
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1456,6 +1486,8 @@ func TestAgreementBlockReplayBug_b29ea57(t *testing.T) {
}
func TestAgreementLateCertBug(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1512,6 +1544,8 @@ func TestAgreementLateCertBug(t *testing.T) {
}
func TestAgreementRecoverGlobalStartingValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1610,6 +1644,8 @@ func TestAgreementRecoverGlobalStartingValue(t *testing.T) {
}
func TestAgreementRecoverGlobalStartingValueBadProposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1711,6 +1747,8 @@ func TestAgreementRecoverGlobalStartingValueBadProposal(t *testing.T) {
}
func TestAgreementRecoverBothVAndBotQuorums(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1834,6 +1872,8 @@ func TestAgreementRecoverBothVAndBotQuorums(t *testing.T) {
}
func TestAgreementSlowPayloadsPreDeadline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1890,6 +1930,8 @@ func TestAgreementSlowPayloadsPreDeadline(t *testing.T) {
}
func TestAgreementSlowPayloadsPostDeadline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -1953,6 +1995,8 @@ func TestAgreementSlowPayloadsPostDeadline(t *testing.T) {
}
func TestAgreementLargePeriods(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
startRound := baseLedger.NextRound()
@@ -2048,6 +2092,8 @@ func (v *testSuspendableBlockValidator) suspend() chan struct{} {
}
func TestAgreementRegression_WrongPeriodPayloadVerificationCancellation_8ba23942(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5
validator := makeTestSuspendableBlockValidator()
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreementWithValidator(t, numNodes, disabled, validator, makeTestLedger)
@@ -2203,6 +2249,8 @@ func TestAgreementRegression_WrongPeriodPayloadVerificationCancellation_8ba23942
// (such as blocks and pipelined messages for the next round)
// Note that the stall will be resolved by catchup even if the relay blocks.
func TestAgreementCertificateDoesNotStallSingleRelay(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numNodes := 5 // single relay, four leaf nodes
relayID := nodeID(0)
baseNetwork, baseLedger, cleanupFn, services, clocks, ledgers, activityMonitor := setupAgreement(t, numNodes, disabled, makeTestLedger)
@@ -2316,6 +2364,8 @@ func TestAgreementCertificateDoesNotStallSingleRelay(t *testing.T) {
}
func TestAgreementServiceStartDeadline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
accessor, err := db.MakeAccessor(t.Name()+"_crash.db", false, true)
require.NoError(t, err)
diff --git a/agreement/voteAggregator_test.go b/agreement/voteAggregator_test.go
index 3cd485a11..99ee6a340 100644
--- a/agreement/voteAggregator_test.go
+++ b/agreement/voteAggregator_test.go
@@ -27,6 +27,7 @@ import (
"github.com/algorand/go-algorand/data/committee"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var voteAggregatorTracer tracer
@@ -36,6 +37,8 @@ func init() {
}
func TestVoteAggregatorVotes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -77,12 +80,16 @@ func TestVoteAggregatorVotes(t *testing.T) {
PlayerLastConcluding: 0,
}}
- router.dispatch(&voteAggregatorTracer, player, e, playerMachine, voteMachine, round, period, step)
+ out := router.dispatch(&voteAggregatorTracer, player, e, playerMachine, voteMachine, round, period, step)
+ fev, ok := out.(filteredEvent)
+ assert.Falsef(t, ok, "voteAggregator should not return a filteredEvent: %v", fev.Err)
}
}
}
func TestVoteAggregatorBundles(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
period := period(0)
@@ -133,7 +140,7 @@ func TestVoteAggregatorBundles(t *testing.T) {
Bundle: bundle,
UnauthenticatedBundle: bundle.u(),
}
- eM := messageEvent{T: voteVerified, Input: msg, Proto: ConsensusVersionView{Version: protocol.ConsensusCurrentVersion}}
+ eM := messageEvent{T: bundleVerified, Input: msg, Proto: ConsensusVersionView{Version: protocol.ConsensusCurrentVersion}}
e := filterableMessageEvent{messageEvent: eM, FreshnessData: freshnessData{
PlayerRound: round,
PlayerPeriod: period,
@@ -141,7 +148,11 @@ func TestVoteAggregatorBundles(t *testing.T) {
PlayerLastConcluding: 0,
}}
- router.dispatch(&voteAggregatorTracer, player, e, playerMachine, voteMachine, bundle.U.Round, bundle.U.Period, bundle.U.Step)
+ out := router.dispatch(&voteAggregatorTracer, player, e, playerMachine, voteMachine, bundle.U.Round, bundle.U.Period, bundle.U.Step)
+ if fev, ok := out.(filteredEvent); ok && fev.Err != nil {
+ assert.NotContainsf(t, fev.Err.String(), "rejected vote due to age: filtered vote from bad round",
+ "voteAggregator should not filter due to age for these events")
+ }
}
}
@@ -150,6 +161,8 @@ func TestVoteAggregatorBundles(t *testing.T) {
*/
func TestVoteAggregatorFiltersVotePresentStale(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -234,6 +247,8 @@ func TestVoteAggregatorFiltersVotePresentStale(t *testing.T) {
}
func TestVoteAggregatorFiltersVoteVerifiedStale(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -309,6 +324,8 @@ func TestVoteAggregatorFiltersVoteVerifiedStale(t *testing.T) {
}
func TestVoteAggregatorFiltersVoteVerifiedThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -364,6 +381,8 @@ func TestVoteAggregatorFiltersVoteVerifiedThreshold(t *testing.T) {
}
func TestVoteAggregatorFiltersBundlePresent(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -466,6 +485,8 @@ func TestVoteAggregatorFiltersBundlePresent(t *testing.T) {
}
func TestVoteAggregatorFiltersBundleVerifiedThresholdStale(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -582,6 +603,8 @@ func TestVoteAggregatorFiltersBundleVerifiedThresholdStale(t *testing.T) {
}
func TestVoteAggregatorFiltersBundleVerifiedRelayStale(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -694,6 +717,8 @@ func TestVoteAggregatorFiltersBundleVerifiedRelayStale(t *testing.T) {
}
func TestVoteAggregatorFiltersVotePresentPeriod(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -779,6 +804,8 @@ func TestVoteAggregatorFiltersVotePresentPeriod(t *testing.T) {
}
func TestVoteAggregatorFiltersVoteNextRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Set up a composed test machine
rRouter := new(rootRouter)
rRouter.update(player{}, 0, false)
@@ -841,6 +868,8 @@ func TestVoteAggregatorFiltersVoteNextRound(t *testing.T) {
}
func TestVoteAggregatorOldVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
cparams := config.Consensus[protocol.ConsensusCurrentVersion]
maxNumBlocks := 2 * cparams.SeedRefreshInterval * cparams.SeedLookback
ledger := makeTestLedgerMaxBlocks(readOnlyGenesis100, maxNumBlocks)
diff --git a/agreement/voteAuxiliary_test.go b/agreement/voteAuxiliary_test.go
index 82a94d594..4528c8643 100644
--- a/agreement/voteAuxiliary_test.go
+++ b/agreement/voteAuxiliary_test.go
@@ -23,6 +23,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// this helper object creates threshold events
@@ -65,6 +66,8 @@ func makeVoteTrackerRoundZero() listener {
}
func TestVoteTrackerPeriodStepCachedThresholdPrivate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// goal: generate a next vote bottom quorum for the given period
// check that Cached is set properly. This is a private
// state test, this file also ensures that the matching event is generated appropriately.
@@ -130,6 +133,8 @@ func TestVoteTrackerPeriodStepCachedThresholdPrivate(t *testing.T) {
// add value threshold only, make sure its returned in status
func TestVoteTrackerPeriodValueStatus(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
v1 := randomBlockHash()
@@ -149,6 +154,8 @@ func TestVoteTrackerPeriodValueStatus(t *testing.T) {
// check seen no thresholds
func TestVoteTrackerPeriodNoneSeen(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
b := testCaseBuilder{}
expectedStatus := nextThresholdStatusEvent{Bottom: false, Proposal: bottom}
b.AddInOutPair(nextThresholdStatusRequestEvent{}, expectedStatus)
@@ -163,6 +170,8 @@ func TestVoteTrackerPeriodNoneSeen(t *testing.T) {
// check seen bottom threshold only
func TestVoteTrackerPeriodBottomOnly(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
in := h.MakeValidNextThresholdVal(t, 1, 1, next, bottom)
@@ -180,6 +189,8 @@ func TestVoteTrackerPeriodBottomOnly(t *testing.T) {
// check seen both bottom and value threshodl
func TestVoteTrackerPeriodValueAndBottom(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
in := h.MakeValidNextThresholdVal(t, 1, 1, next, bottom)
@@ -202,6 +213,8 @@ func TestVoteTrackerPeriodValueAndBottom(t *testing.T) {
/* VoteTrackerRound Tests */
func TestVoteTrackerRoundUpdatesFreshest(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
v1 := randomBlockHash()
@@ -220,6 +233,8 @@ func TestVoteTrackerRoundUpdatesFreshest(t *testing.T) {
}
func TestVoteTrackerRoundUpdatesFreshestNextOverSoft(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
v1 := randomBlockHash()
@@ -244,6 +259,8 @@ func TestVoteTrackerRoundUpdatesFreshestNextOverSoft(t *testing.T) {
}
func TestVoteTrackerRoundUpdatesFreshestPeriod(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
v1 := randomBlockHash()
@@ -268,6 +285,8 @@ func TestVoteTrackerRoundUpdatesFreshestPeriod(t *testing.T) {
}
func TestVoteTrackerRoundUpdatesFreshestBot(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := nextThresholdHelper{}
b := testCaseBuilder{}
v1 := randomBlockHash()
@@ -297,6 +316,8 @@ func TestVoteTrackerRoundUpdatesFreshestBot(t *testing.T) {
}
func TestVoteTrackerRoundForwardsVoteAccepted(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// check forwards vote accepted, and returns only a fresh bundle
// this is really a test on the composition of machines. We should build
// a framework for composing tests instead of writing these e2e's in the future.
diff --git a/agreement/voteTracker_test.go b/agreement/voteTracker_test.go
index bc7e38958..2cec6b83b 100644
--- a/agreement/voteTracker_test.go
+++ b/agreement/voteTracker_test.go
@@ -23,6 +23,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// todo: test validity of threshold events (incl. bundles)
@@ -36,6 +37,8 @@ func makeVoteTrackerZero() listener {
// actual tests
func TestVoteTrackerNoOp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -58,6 +61,8 @@ func TestVoteTrackerNoOp(t *testing.T) {
}
func TestVoteTrackerSoftQuorum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -100,6 +105,8 @@ func TestVoteTrackerSoftQuorum(t *testing.T) {
// sanity check for cert quorums
func TestVoteTrackerCertQuorum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -141,6 +148,8 @@ func TestVoteTrackerCertQuorum(t *testing.T) {
// sanity check for next quorums
func TestVoteTrackerNextQuorum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -182,6 +191,8 @@ func TestVoteTrackerNextQuorum(t *testing.T) {
// sanity check propose votes don't trigger anything
func TestVoteTrackerProposeNoOp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -208,6 +219,8 @@ func TestVoteTrackerProposeNoOp(t *testing.T) {
}
func TestVoteTrackerEquivocatorWeightCountedOnce(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -236,6 +249,8 @@ func TestVoteTrackerEquivocatorWeightCountedOnce(t *testing.T) {
}
func TestVoteTrackerEquivDoesntReemitThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -272,6 +287,8 @@ func TestVoteTrackerEquivDoesntReemitThreshold(t *testing.T) {
}
func TestVoteTrackerEquivocationsCount(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -319,6 +336,8 @@ func TestVoteTrackerEquivocationsCount(t *testing.T) {
// same test as before, except equivocations voting v2, v3 should also count towards quorum for v1
func TestVoteTrackerSuperEquivocationsCount(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -370,6 +389,8 @@ func TestVoteTrackerSuperEquivocationsCount(t *testing.T) {
// check that SM panics on seeing two quorums
func TestVoteTrackerPanicsOnTwoSoftQuorums(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -411,6 +432,8 @@ func TestVoteTrackerPanicsOnTwoSoftQuorums(t *testing.T) {
// check that SM panics on seeing soft quorum for bot (currently enforced by contract)
func TestVoteTrackerPanicsOnSoftBotQuorum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -442,6 +465,8 @@ func TestVoteTrackerPanicsOnSoftBotQuorum(t *testing.T) {
// check that SM panics on seeing two next quorums, in particular bot, val in same step.
func TestVoteTrackerPanicsOnTwoNextQuorums(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
@@ -480,6 +505,8 @@ func TestVoteTrackerPanicsOnTwoNextQuorums(t *testing.T) {
}
func TestVoteTrackerRejectsTooManyEquivocators(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
Num := soft.threshold(config.Consensus[protocol.ConsensusCurrentVersion])
@@ -508,6 +535,8 @@ func TestVoteTrackerRejectsTooManyEquivocators(t *testing.T) {
/* tests for filtering component of vote tracker */
func TestVoteTrackerFiltersDuplicateVoteOnce(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
v1 := randomBlockHash()
@@ -538,6 +567,8 @@ func TestVoteTrackerFiltersDuplicateVoteOnce(t *testing.T) {
}
func TestVoteTrackerForwardsFirstEquivocation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
const V1Bound = 10
@@ -605,6 +636,8 @@ func TestVoteTrackerForwardsFirstEquivocation(t *testing.T) {
}
func TestVoteTrackerFiltersFutureEquivocations(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
helper := voteMakerHelper{}
helper.Setup()
const Num = 100
@@ -650,6 +683,8 @@ func TestVoteTrackerFiltersFutureEquivocations(t *testing.T) {
/* Check that machine panics on unknown event */
func TestVoteTrackerRejectsUnknownEvent(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testCase := determisticTraceTestCase{
inputs: []event{
emptyEvent{},
diff --git a/agreement/vote_test.go b/agreement/vote_test.go
index aa9b74f77..7c5ed7855 100644
--- a/agreement/vote_test.go
+++ b/agreement/vote_test.go
@@ -28,6 +28,7 @@ import (
"github.com/algorand/go-algorand/data/committee"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// error is set if this address is not selected
@@ -43,6 +44,8 @@ func makeVoteTesting(addr basics.Address, vrfSecs *crypto.VRFSecrets, otSecs cry
}
func TestVoteValidation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numAddresses := 50
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
@@ -115,6 +118,8 @@ func TestVoteValidation(t *testing.T) {
}
func TestVoteReproposalValidation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numAddresses := 50
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
@@ -173,6 +178,8 @@ func TestVoteReproposalValidation(t *testing.T) {
}
func TestVoteMakeVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
@@ -212,6 +219,7 @@ func makeVotePanicWrapper(t *testing.T, message string, rv rawVote, voting crypt
}
func TestVoteValidationStepCertAndProposalBottom(t *testing.T) {
+ partitiontest.PartitionTest(t)
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
@@ -242,6 +250,8 @@ func TestVoteValidationStepCertAndProposalBottom(t *testing.T) {
// Test Equivocation Vote Validation
func TestEquivocationVoteValidation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numAddresses := 50
ledger, addresses, vrfSecrets, otSecrets := readOnlyFixture100()
round := ledger.NextRound()
diff --git a/catchup/ledgerFetcher_test.go b/catchup/ledgerFetcher_test.go
index 555389531..73404f873 100644
--- a/catchup/ledgerFetcher_test.go
+++ b/catchup/ledgerFetcher_test.go
@@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type dummyLedgerFetcherReporter struct {
@@ -40,6 +41,8 @@ func (lf *dummyLedgerFetcherReporter) updateLedgerFetcherProgress(*ledger.Catchp
}
func TestNoPeersAvailable(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
lf := makeLedgerFetcher(&mocks.MockNetwork{}, &mocks.MockCatchpointCatchupAccessor{}, logging.TestingLog(t), &dummyLedgerFetcherReporter{}, config.GetDefaultLocal())
var peer network.Peer
peer = &lf // The peer is an opaque interface.. we can add anything as a Peer.
@@ -48,6 +51,8 @@ func TestNoPeersAvailable(t *testing.T) {
}
func TestNonParsableAddress(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
lf := makeLedgerFetcher(&mocks.MockNetwork{}, &mocks.MockCatchpointCatchupAccessor{}, logging.TestingLog(t), &dummyLedgerFetcherReporter{}, config.GetDefaultLocal())
peer := testHTTPPeer(":def")
err := lf.getPeerLedger(context.Background(), &peer, basics.Round(0))
@@ -55,6 +60,8 @@ func TestNonParsableAddress(t *testing.T) {
}
func TestLedgerFetcherErrorResponseHandling(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// create a dummy server.
mux := http.NewServeMux()
s := &http.Server{
diff --git a/catchup/peerSelector_test.go b/catchup/peerSelector_test.go
index c86267e51..5c7bb9344 100644
--- a/catchup/peerSelector_test.go
+++ b/catchup/peerSelector_test.go
@@ -29,6 +29,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type mockHTTPPeer struct {
@@ -63,6 +64,8 @@ func (d *mockUnicastPeer) Respond(ctx context.Context, reqMsg network.IncomingMe
}
func TestPeerAddress(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
httpPeer := &mockHTTPPeer{address: "12345"}
require.Equal(t, "12345", peerAddress(httpPeer))
@@ -74,6 +77,8 @@ func TestPeerAddress(t *testing.T) {
}
func TestDownloadDurationToRank(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// verify mid value
require.Equal(t, 1500, downloadDurationToRank(50*time.Millisecond, 0*time.Millisecond, 100*time.Millisecond, 1000, 2000))
// check bottom
@@ -112,6 +117,8 @@ func makePeersRetrieverStub(fnc func(options ...network.PeerOption) []network.Pe
}
}
func TestPeerSelector(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
peers := []network.Peer{&mockHTTPPeer{address: "12345"}}
peerSelector := makePeerSelector(
@@ -170,6 +177,8 @@ func TestPeerSelector(t *testing.T) {
}
func TestPeerDownloadRanking(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
peers1 := []network.Peer{&mockHTTPPeer{address: "1234"}, &mockHTTPPeer{address: "5678"}}
peers2 := []network.Peer{&mockHTTPPeer{address: "abcd"}, &mockHTTPPeer{address: "efgh"}}
@@ -219,6 +228,8 @@ func TestPeerDownloadRanking(t *testing.T) {
}
func TestFindMissingPeer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
peerSelector := makePeerSelector(
makePeersRetrieverStub(func(options ...network.PeerOption) []network.Peer {
return []network.Peer{}
@@ -231,6 +242,7 @@ func TestFindMissingPeer(t *testing.T) {
}
func TestHistoricData(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}, &mockHTTPPeer{address: "a2"}, &mockHTTPPeer{address: "a3"}}
peers2 := []network.Peer{&mockHTTPPeer{address: "b1"}, &mockHTTPPeer{address: "b2"}}
@@ -303,6 +315,7 @@ func peerSelectorTestRandVal(t *testing.T, seed int) float64 {
return randVal
}
func TestPeersDownloadFailed(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}, &mockHTTPPeer{address: "a2"}, &mockHTTPPeer{address: "a3"}}
peers2 := []network.Peer{&mockHTTPPeer{address: "b1"}, &mockHTTPPeer{address: "b2"}}
@@ -377,6 +390,7 @@ func TestPeersDownloadFailed(t *testing.T) {
// TestPenalty tests that the penalty is calculated correctly and one peer
// is not dominating all the selection.
func TestPenalty(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}, &mockHTTPPeer{address: "a2"}, &mockHTTPPeer{address: "a3"}}
peers2 := []network.Peer{&mockHTTPPeer{address: "b1"}, &mockHTTPPeer{address: "b2"}}
@@ -434,6 +448,7 @@ func TestPenalty(t *testing.T) {
// TestPeerDownloadDurationToRank tests all the cases handled by peerDownloadDurationToRank
func TestPeerDownloadDurationToRank(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}, &mockHTTPPeer{address: "a2"}, &mockHTTPPeer{address: "a3"}}
peers2 := []network.Peer{&mockHTTPPeer{address: "b1"}, &mockHTTPPeer{address: "b2"}}
@@ -474,6 +489,8 @@ func TestPeerDownloadDurationToRank(t *testing.T) {
}
func TestLowerUpperBounds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
classes := []peerClass{{initialRank: peerRankInitialFirstPriority, peerClass: network.PeersPhonebookArchivers},
{initialRank: peerRankInitialSecondPriority, peerClass: network.PeersPhonebookRelays},
{initialRank: peerRankInitialThirdPriority, peerClass: network.PeersConnectedOut},
@@ -491,6 +508,8 @@ func TestLowerUpperBounds(t *testing.T) {
}
func TestFullResetRequestPenalty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
class := peerClass{initialRank: 10, peerClass: network.PeersPhonebookArchivers}
hs := makeHistoricStatus(10, class)
hs.push(5, 1, class)
@@ -504,6 +523,7 @@ func TestFullResetRequestPenalty(t *testing.T) {
// This was a bug where the resetRequestPenalty was not bounding the returned rank, and was having download failures.
// Initializing rankSamples to 0 makes this works, since the dropped value subtracts 0 from rankSum.
func TestClassUpperBound(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}, &mockHTTPPeer{address: "a2"}}
pClass := peerClass{initialRank: peerRankInitialSecondPriority, peerClass: network.PeersPhonebookArchivers}
@@ -537,6 +557,7 @@ func TestClassUpperBound(t *testing.T) {
// This was a bug where the resetRequestPenalty was not bounding the returned rank, and the rankSum was not
// initialized to give the average of class.initialRank
func TestClassLowerBound(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}, &mockHTTPPeer{address: "a2"}}
pClass := peerClass{initialRank: peerRankInitialSecondPriority, peerClass: network.PeersPhonebookArchivers}
@@ -565,6 +586,7 @@ func TestClassLowerBound(t *testing.T) {
// TestEviction tests that the peer is evicted after several download failures, and it handles same address for different peer classes
func TestEvictionAndUpgrade(t *testing.T) {
+ partitiontest.PartitionTest(t)
peers1 := []network.Peer{&mockHTTPPeer{address: "a1"}}
peers2 := []network.Peer{&mockHTTPPeer{address: "a1"}}
diff --git a/catchup/service.go b/catchup/service.go
index 9e762e377..211b31608 100644
--- a/catchup/service.go
+++ b/catchup/service.go
@@ -307,7 +307,8 @@ func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool,
}
if s.cfg.CatchupVerifyTransactionSignatures() || s.cfg.CatchupVerifyApplyData() {
- vb, err := s.ledger.Validate(s.ctx, *block, s.blockValidationPool)
+ var vb *ledger.ValidatedBlock
+ vb, err = s.ledger.Validate(s.ctx, *block, s.blockValidationPool)
if err != nil {
if s.ctx.Err() != nil {
// if the context expired, just exit.
diff --git a/catchup/service_test.go b/catchup/service_test.go
index 1ca3aa63b..a0df457a1 100644
--- a/catchup/service_test.go
+++ b/catchup/service_test.go
@@ -40,6 +40,7 @@ import (
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/rpcs"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/execpool"
)
@@ -129,6 +130,8 @@ func (auth *mockedAuthenticator) alter(errorRound int, fail bool) {
}
func TestServiceFetchBlocksSameRange(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Ledgers
local := new(mockedLedger)
local.blocks = append(local.blocks, bookkeeping.Block{})
@@ -178,6 +181,8 @@ func (cl *periodicSyncLogger) Warnf(s string, args ...interface{}) {
}
func TestPeriodicSync(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Ledger
local := new(mockedLedger)
local.blocks = append(local.blocks, bookkeeping.Block{})
@@ -240,6 +245,8 @@ func TestPeriodicSync(t *testing.T) {
}
func TestServiceFetchBlocksOneBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Ledger
numBlocks := 10
local := new(mockedLedger)
@@ -296,6 +303,8 @@ func TestServiceFetchBlocksOneBlock(t *testing.T) {
// When caught up, and the agreement service is taking the lead, the sync() stops and
// yields to the agreement. Agreement is emulated by the go func() loop in the test
func TestAbruptWrites(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numberOfBlocks := 100
if testing.Short() {
@@ -354,6 +363,8 @@ func TestAbruptWrites(t *testing.T) {
}
func TestServiceFetchBlocksMultiBlocks(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Ledger
numberOfBlocks := basics.Round(100)
if testing.Short() {
@@ -410,6 +421,8 @@ func TestServiceFetchBlocksMultiBlocks(t *testing.T) {
}
func TestServiceFetchBlocksMalformed(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Ledger
numBlocks := 10
local := new(mockedLedger)
@@ -452,6 +465,7 @@ func TestServiceFetchBlocksMalformed(t *testing.T) {
// Test the interruption in the initial loop
// This cannot happen in practice, but is used to test the code.
func TestOnSwitchToUnSupportedProtocol1(t *testing.T) {
+ partitiontest.PartitionTest(t)
lastRoundRemote := 5
lastRoundLocal := 0
@@ -470,6 +484,7 @@ func TestOnSwitchToUnSupportedProtocol1(t *testing.T) {
// Test the interruption in "the rest" loop
func TestOnSwitchToUnSupportedProtocol2(t *testing.T) {
+ partitiontest.PartitionTest(t)
lastRoundRemote := 10
lastRoundLocal := 7
@@ -491,6 +506,7 @@ func TestOnSwitchToUnSupportedProtocol2(t *testing.T) {
// This can not happen in practice, because there will be
// enough rounds for the protocol upgrade notice.
func TestOnSwitchToUnSupportedProtocol3(t *testing.T) {
+ partitiontest.PartitionTest(t)
lastRoundRemote := 14
lastRoundLocal := 7
@@ -516,6 +532,7 @@ func TestOnSwitchToUnSupportedProtocol3(t *testing.T) {
// happen when the catchup service restart at the round when
// an upgrade happens.
func TestOnSwitchToUnSupportedProtocol4(t *testing.T) {
+ partitiontest.PartitionTest(t)
lastRoundRemote := 14
lastRoundLocal := 7
@@ -757,6 +774,8 @@ func (s *Service) testStart() {
}
func TestCatchupUnmatchedCertificate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Ledger
numBlocks := 10
local := new(mockedLedger)
@@ -800,6 +819,8 @@ func TestCatchupUnmatchedCertificate(t *testing.T) {
// TestCreatePeerSelector tests if the correct peer selector coonfigurations are prepared
func TestCreatePeerSelector(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make Service
cfg := defaultConfig
@@ -923,6 +944,8 @@ func TestCreatePeerSelector(t *testing.T) {
}
func TestServiceStartStop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
cfg := defaultConfig
ledger := new(mockedLedger)
ledger.blocks = append(ledger.blocks, bookkeeping.Block{})
@@ -934,6 +957,8 @@ func TestServiceStartStop(t *testing.T) {
}
func TestSynchronizingTime(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
cfg := defaultConfig
ledger := new(mockedLedger)
ledger.blocks = append(ledger.blocks, bookkeeping.Block{})
diff --git a/catchup/universalFetcher_test.go b/catchup/universalFetcher_test.go
index 4a730b74d..28cd0b566 100644
--- a/catchup/universalFetcher_test.go
+++ b/catchup/universalFetcher_test.go
@@ -34,10 +34,12 @@ import (
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/rpcs"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// TestUGetBlockWs tests the universal fetcher ws peer case
func TestUGetBlockWs(t *testing.T) {
+ partitiontest.PartitionTest(t)
cfg := config.GetDefaultLocal()
@@ -79,6 +81,7 @@ func TestUGetBlockWs(t *testing.T) {
// TestUGetBlockHTTP tests the universal fetcher http peer case
func TestUGetBlockHTTP(t *testing.T) {
+ partitiontest.PartitionTest(t)
cfg := config.GetDefaultLocal()
@@ -124,6 +127,8 @@ func TestUGetBlockHTTP(t *testing.T) {
// TestUGetBlockUnsupported tests the handling of an unsupported peer
func TestUGetBlockUnsupported(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
fetcher := universalBlockFetcher{}
peer := ""
block, cert, duration, err := fetcher.fetchBlock(context.Background(), 1, peer)
@@ -136,6 +141,7 @@ func TestUGetBlockUnsupported(t *testing.T) {
// TestprocessBlockBytesErrors checks the error handling in processBlockBytes
func TestProcessBlockBytesErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
blk := bookkeeping.Block{
BlockHeader: bookkeeping.BlockHeader{
@@ -167,6 +173,7 @@ func TestProcessBlockBytesErrors(t *testing.T) {
// TestRequestBlockBytesErrors checks the error handling in requestBlockBytes
func TestRequestBlockBytesErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
cfg := config.GetDefaultLocal()
@@ -232,6 +239,7 @@ func (thh *TestHTTPHandler) ServeHTTP(response http.ResponseWriter, request *htt
// TestGetBlockBytesHTTPErrors tests the errors reported from getblockBytes for http peer
func TestGetBlockBytesHTTPErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
cfg := config.GetDefaultLocal()
net := &httpTestPeerSource{}
@@ -280,6 +288,8 @@ func (et ErrTest) Error() string {
// TestErrorTypes tests the error types are implemented correctly
func TestErrorTypes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
err1 := makeErrWrongCertFromPeer(1, 2, "somepeer1")
require.Equal(t, "processBlockBytes: got wrong cert from peer somepeer1: wanted 1, got 2", err1.Error())
diff --git a/cmd/goal/account.go b/cmd/goal/account.go
index ebda0935e..f4c36fcc5 100644
--- a/cmd/goal/account.go
+++ b/cmd/goal/account.go
@@ -31,7 +31,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/crypto/passphrase"
- "github.com/algorand/go-algorand/daemon/algod/api/spec/v1"
+ v1 "github.com/algorand/go-algorand/daemon/algod/api/spec/v1"
algodAcct "github.com/algorand/go-algorand/data/account"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
@@ -1195,7 +1195,6 @@ var importRootKeysCmd = &cobra.Command{
handle, err = db.MakeErasableAccessor(filepath.Join(keyDir, filename))
if err != nil {
// Couldn't open it, skip it
- err = nil
continue
}
@@ -1204,7 +1203,6 @@ var importRootKeysCmd = &cobra.Command{
handle.Close()
if err != nil {
// Couldn't read it, skip it
- err = nil
continue
}
diff --git a/cmd/goal/messages.go b/cmd/goal/messages.go
index 5cd66e99b..2b75258e4 100644
--- a/cmd/goal/messages.go
+++ b/cmd/goal/messages.go
@@ -75,7 +75,7 @@ const (
errorNodeRunning = "Node must be stopped before writing APIToken"
errorNodeFailGenToken = "Cannot generate API token: %s"
errorNodeCreation = "Error during node creation: %v"
- errorNodeManagedBySystemd = "This node is managed by systemd, you must run the following command to make your desired state change to your node:\n\nsystemctl %s algorand.service"
+ errorNodeManagedBySystemd = "This node is using systemd and should be managed with systemctl. For additional information refer to https://developer.algorand.org/docs/run-a-node/setup/install/#installing-algod-as-a-systemd-service"
errorKill = "Cannot kill node: %s"
errorCloningNode = "Error cloning the node: %s"
infoNodeCloned = "Node cloned successfully to: %s"
diff --git a/cmd/goal/node.go b/cmd/goal/node.go
index dd42e2381..5e22df5a2 100644
--- a/cmd/goal/node.go
+++ b/cmd/goal/node.go
@@ -165,7 +165,7 @@ var startCmd = &cobra.Command{
}
onDataDirs(func(dataDir string) {
if libgoal.AlgorandDaemonSystemdManaged(dataDir) {
- reportErrorf(errorNodeManagedBySystemd, "start")
+ reportErrorf(errorNodeManagedBySystemd)
}
nc := nodecontrol.MakeNodeController(binDir, dataDir)
@@ -237,7 +237,7 @@ var stopCmd = &cobra.Command{
}
onDataDirs(func(dataDir string) {
if libgoal.AlgorandDaemonSystemdManaged(dataDir) {
- reportErrorf(errorNodeManagedBySystemd, "stop")
+ reportErrorf(errorNodeManagedBySystemd)
}
nc := nodecontrol.MakeNodeController(binDir, dataDir)
@@ -268,7 +268,7 @@ var restartCmd = &cobra.Command{
}
onDataDirs(func(dataDir string) {
if libgoal.AlgorandDaemonSystemdManaged(dataDir) {
- reportErrorf(errorNodeManagedBySystemd, "restart")
+ reportErrorf(errorNodeManagedBySystemd)
}
nc := nodecontrol.MakeNodeController(binDir, dataDir)
diff --git a/cmd/partitiontest_linter/go.mod b/cmd/partitiontest_linter/go.mod
new file mode 100644
index 000000000..d9e2120c6
--- /dev/null
+++ b/cmd/partitiontest_linter/go.mod
@@ -0,0 +1,5 @@
+module github.com/algorand/go-algorand/cmd/partitiontest_linter
+
+go 1.16
+
+require golang.org/x/tools v0.1.3
diff --git a/cmd/partitiontest_linter/go.sum b/cmd/partitiontest_linter/go.sum
new file mode 100644
index 000000000..e652f3edc
--- /dev/null
+++ b/cmd/partitiontest_linter/go.sum
@@ -0,0 +1,27 @@
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.3 h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8=
+golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/cmd/partitiontest_linter/linter.go b/cmd/partitiontest_linter/linter.go
new file mode 100644
index 000000000..27ffbf14e
--- /dev/null
+++ b/cmd/partitiontest_linter/linter.go
@@ -0,0 +1,132 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package linter
+
+import (
+ "go/ast"
+ "strings"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+const packageName string = "partitiontest"
+const functionName string = "PartitionTest"
+const fileNameSuffix string = "_test.go"
+const functionNamePrefix string = "Test"
+const parameterType string = "T"
+
+// Analyzer initilization
+var Analyzer = &analysis.Analyzer{
+ Name: "lint",
+ Doc: "This custom linter checks inside files that end in '_test.go', and inside functions that start with 'Test' and have testing argument, for a line 'partitiontest.ParitionTest(<testing arg>)'",
+ Run: run,
+}
+
+func run(pass *analysis.Pass) (interface{}, error) {
+ for _, f := range pass.Files {
+ currentFileName := pass.Fset.File(f.Pos()).Name()
+ if !strings.HasSuffix(currentFileName, fileNameSuffix) {
+ continue
+ }
+ for _, decl := range f.Decls {
+ fn, ok := decl.(*ast.FuncDecl)
+ if !ok || fn.Recv != nil {
+ // Ignore non-functions or functions with receivers.
+ continue
+ }
+
+ // Check that function name starts with "Test"
+ if !strings.HasPrefix(fn.Name.Name, functionNamePrefix) {
+ continue
+ }
+
+ if !isTestParameterInFunction(fn.Type.Params.List[0].Type, parameterType) {
+ continue
+ }
+ if !isSearchLineInFunction(fn) {
+ pass.Reportf(fn.Pos(), "%s function is missing %s.%s(<%s type parameter>)", fn.Name.Name, packageName, functionName, parameterType)
+ }
+
+ }
+ }
+ return nil, nil
+}
+
+func isTestParameterInFunction(typ ast.Expr, wantType string) bool {
+ ptr, ok := typ.(*ast.StarExpr)
+ if !ok {
+ // Not a pointer.
+ return false
+ }
+
+ if name, ok := ptr.X.(*ast.Ident); ok {
+ return name.Name == wantType
+ }
+ if sel, ok := ptr.X.(*ast.SelectorExpr); ok {
+ return sel.Sel.Name == wantType
+ }
+ return false
+}
+
+func isSearchLineInFunction(fn *ast.FuncDecl) bool {
+ for _, oneline := range fn.Body.List {
+ if exprStmt, ok := oneline.(*ast.ExprStmt); ok {
+ if call, ok := exprStmt.X.(*ast.CallExpr); ok {
+ if fun, ok := call.Fun.(*ast.SelectorExpr); ok {
+ if !doesPackageNameMatch(fun) {
+ continue
+ }
+ if !doesFunctionNameMatch(fun) {
+ continue
+ }
+ }
+
+ if !doesParameterNameMatch(call, fn) {
+ continue
+ }
+
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func doesPackageNameMatch(fun *ast.SelectorExpr) bool {
+ if packageobject, ok := fun.X.(*ast.Ident); ok {
+ if packageobject.Name == packageName {
+ return true
+ }
+ }
+ return false
+}
+
+func doesFunctionNameMatch(fun *ast.SelectorExpr) bool {
+ return fun.Sel.Name == functionName
+}
+
+func doesParameterNameMatch(call *ast.CallExpr, fn *ast.FuncDecl) bool {
+ for _, oneArg := range call.Args {
+
+ if realArg, ok := oneArg.(*ast.Ident); ok {
+ if realArg.Obj.Name == fn.Type.Params.List[0].Names[0].Obj.Name {
+ return true
+ }
+ }
+ }
+ return false
+}
diff --git a/cmd/partitiontest_linter/linter_test.go b/cmd/partitiontest_linter/linter_test.go
new file mode 100644
index 000000000..4d53e3ed3
--- /dev/null
+++ b/cmd/partitiontest_linter/linter_test.go
@@ -0,0 +1,27 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package linter
+
+import (
+ "testing"
+
+ "golang.org/x/tools/go/analysis/analysistest"
+)
+
+func TestAll(t *testing.T) {
+ analysistest.Run(t, analysistest.TestData(), Analyzer)
+}
diff --git a/util/metrics/gaugeCommon.go b/cmd/partitiontest_linter/plugin/plugin.go
index 49b617cb8..16b9ee08c 100644
--- a/util/metrics/gaugeCommon.go
+++ b/cmd/partitiontest_linter/plugin/plugin.go
@@ -14,26 +14,26 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
-package metrics
+package main
import (
- "time"
-
- "github.com/algorand/go-deadlock"
+ linter "github.com/algorand/go-algorand/cmd/partitiontest_linter"
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/singlechecker"
)
-// Gauge represent a single gauge variable.
-type Gauge struct {
- deadlock.Mutex
- name string
- description string
- labels map[string]int // map each label ( i.e. httpErrorCode ) to an index.
- valuesIndices map[int]*gaugeValues // maps each set of labels into a concrete gauge
+type analyzerPlugin struct{}
+
+// This must be implemented
+func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
+ return []*analysis.Analyzer{
+ linter.Analyzer,
+ }
}
-type gaugeValues struct {
- gauge float64
- timestamp time.Time
- labels map[string]string
- formattedLabels string
+// This must be defined and named 'AnalyzerPlugin'
+var AnalyzerPlugin analyzerPlugin
+
+func main() {
+ singlechecker.Main(linter.Analyzer)
}
diff --git a/cmd/partitiontest_linter/testdata/linter_testdata_test.go b/cmd/partitiontest_linter/testdata/linter_testdata_test.go
new file mode 100644
index 000000000..f11d76261
--- /dev/null
+++ b/cmd/partitiontest_linter/testdata/linter_testdata_test.go
@@ -0,0 +1,73 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+/*
+This file is input file for analyzer_test.go
+That's why we are using relative path in import below
+It is also why we named this file _test.go, since linter only looks at files that end in _test.go
+*/
+
+package linter_testdata
+
+import (
+ "testing"
+
+ "../../../test/partitiontest"
+)
+
+func notTestFunction() {}
+
+func notTestFunctionWithWrongParam(t string) {}
+
+func notTestFunctionWithCorrectParam(t *testing.T) {}
+
+func notTestFunctionWithCorrectParamCorrectLine(t *testing.T) {
+ partitiontest.PartitionTest(t)
+}
+
+func notTestFunctionWithCorrectParamWrongLine(t *testing.T) {
+ println("something")
+}
+
+func TestFunctionWithCorrectParamOnly(t *testing.T) {} // want "function is missing partitiontest.PartitionTest"
+
+func TestFunctionWithCorrectParamCorrectLine(t *testing.T) {
+ partitiontest.PartitionTest(t)
+}
+
+func TestFunctionWithCorrectParamBadLine(t *testing.T) { // want "function is missing partitiontest.PartitionTest"
+ println("something")
+}
+
+func TestFunctionWithDifferentName(n *testing.T) {
+ partitiontest.PartitionTest(n)
+}
+
+func TestFunctionWithCorrectParamNotFirstCorrectLine(t *testing.T) {
+ println("something")
+ partitiontest.PartitionTest(t)
+}
+
+func TestFunctionWithCorrectParamNotLastCorrectLine(t *testing.T) {
+ partitiontest.PartitionTest(t)
+ println("something")
+}
+
+func TestFunctionWithCorrectParamMiddleCorrectLine(t *testing.T) {
+ println("something")
+ partitiontest.PartitionTest(t)
+ println("something")
+}
diff --git a/cmd/tealdbg/cdtState.go b/cmd/tealdbg/cdtState.go
index 8919029a4..dca4a3ff9 100644
--- a/cmd/tealdbg/cdtState.go
+++ b/cmd/tealdbg/cdtState.go
@@ -368,7 +368,7 @@ func prepareTxn(txn *transactions.Transaction, groupIndex int) []fieldDesc {
continue
}
var value string
- var valType string = "string"
+ var valType string
tv, err := logic.TxnFieldToTealValue(txn, groupIndex, logic.TxnField(field), 0)
if err != nil {
value = err.Error()
diff --git a/cmd/tealdbg/localLedger.go b/cmd/tealdbg/localLedger.go
index b33a23edd..6f4dcfeaa 100644
--- a/cmd/tealdbg/localLedger.go
+++ b/cmd/tealdbg/localLedger.go
@@ -187,10 +187,13 @@ func getAppCreatorFromIndexer(indexerURL string, indexerToken string, app basics
queryString := fmt.Sprintf("%s/v2/applications/%d", indexerURL, app)
client := &http.Client{}
request, err := http.NewRequest("GET", queryString, nil)
+ if err != nil {
+ return basics.Address{}, fmt.Errorf("application request error: %w", err)
+ }
request.Header.Set("X-Indexer-API-Token", indexerToken)
resp, err := client.Do(request)
if err != nil {
- return basics.Address{}, fmt.Errorf("application request error: %s", err)
+ return basics.Address{}, fmt.Errorf("application request error: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
@@ -200,13 +203,13 @@ func getAppCreatorFromIndexer(indexerURL string, indexerToken string, app basics
var appResp ApplicationIndexerResponse
err = json.NewDecoder(resp.Body).Decode(&appResp)
if err != nil {
- return basics.Address{}, fmt.Errorf("application response decode error: %s", err)
+ return basics.Address{}, fmt.Errorf("application response decode error: %w", err)
}
creator, err := basics.UnmarshalChecksumAddress(appResp.Application.Params.Creator)
if err != nil {
- return basics.Address{}, fmt.Errorf("UnmarshalChecksumAddress error: %s", err)
+ return basics.Address{}, fmt.Errorf("UnmarshalChecksumAddress error: %w", err)
}
return creator, nil
}
@@ -215,10 +218,13 @@ func getBalanceFromIndexer(indexerURL string, indexerToken string, account basic
queryString := fmt.Sprintf("%s/v2/accounts/%s?round=%d", indexerURL, account, round)
client := &http.Client{}
request, err := http.NewRequest("GET", queryString, nil)
+ if err != nil {
+ return basics.AccountData{}, fmt.Errorf("account request error: %w", err)
+ }
request.Header.Set("X-Indexer-API-Token", indexerToken)
resp, err := client.Do(request)
if err != nil {
- return basics.AccountData{}, fmt.Errorf("account request error: %s", err)
+ return basics.AccountData{}, fmt.Errorf("account request error: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
@@ -228,11 +234,11 @@ func getBalanceFromIndexer(indexerURL string, indexerToken string, account basic
var accountResp AccountIndexerResponse
err = json.NewDecoder(resp.Body).Decode(&accountResp)
if err != nil {
- return basics.AccountData{}, fmt.Errorf("account response decode error: %s", err)
+ return basics.AccountData{}, fmt.Errorf("account response decode error: %w", err)
}
balance, err := v2.AccountToAccountData(&accountResp.Account)
if err != nil {
- return basics.AccountData{}, fmt.Errorf("AccountToAccountData error: %s", err)
+ return basics.AccountData{}, fmt.Errorf("AccountToAccountData error: %w", err)
}
return balance, nil
}
diff --git a/compactcert/db_test.go b/compactcert/db_test.go
index a4c98e1e3..e34eb8fbb 100644
--- a/compactcert/db_test.go
+++ b/compactcert/db_test.go
@@ -28,6 +28,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
@@ -48,6 +49,8 @@ func dbOpenTest(t testing.TB, inMemory bool) (db.Pair, string) {
}
func TestPendingSigDB(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbs, _ := dbOpenTest(t, true)
defer dbs.Close()
diff --git a/compactcert/msgp_gen_test.go b/compactcert/msgp_gen_test.go
index e56d3bca8..88c8395a3 100644
--- a/compactcert/msgp_gen_test.go
+++ b/compactcert/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalsigFromAddr(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := sigFromAddr{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/compactcert/worker_test.go b/compactcert/worker_test.go
index cd3351e82..e8b2554cc 100644
--- a/compactcert/worker_test.go
+++ b/compactcert/worker_test.go
@@ -38,6 +38,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
"github.com/algorand/go-deadlock"
)
@@ -213,6 +214,8 @@ func newPartKey(t testing.TB, parent basics.Address) account.Participation {
}
func TestWorkerAllSigs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var keys []account.Participation
for i := 0; i < 10; i++ {
var parent basics.Address
@@ -273,6 +276,8 @@ func TestWorkerAllSigs(t *testing.T) {
}
func TestWorkerPartialSigs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var keys []account.Participation
for i := 0; i < 7; i++ {
var parent basics.Address
@@ -329,6 +334,8 @@ func TestWorkerPartialSigs(t *testing.T) {
}
func TestWorkerInsufficientSigs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var keys []account.Participation
for i := 0; i < 2; i++ {
var parent basics.Address
@@ -358,6 +365,8 @@ func TestWorkerInsufficientSigs(t *testing.T) {
}
func TestLatestSigsFromThisNode(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var keys []account.Participation
for i := 0; i < 10; i++ {
var parent basics.Address
@@ -395,6 +404,8 @@ func TestLatestSigsFromThisNode(t *testing.T) {
}
func TestWorkerRestart(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var keys []account.Participation
for i := 0; i < 10; i++ {
var parent basics.Address
@@ -434,6 +445,8 @@ func TestWorkerRestart(t *testing.T) {
}
func TestWorkerHandleSig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var keys []account.Participation
for i := 0; i < 2; i++ {
var parent basics.Address
diff --git a/config/config_test.go b/config/config_test.go
index 259044363..0c8033279 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -29,6 +29,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/codecs"
)
@@ -41,6 +42,8 @@ var defaultConfig = Local{
}
func TestSaveThenLoad(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
c1, err := loadWithoutDefaults(defaultConfig)
require.NoError(t, err)
c1, err = migrate(c1)
@@ -68,12 +71,16 @@ func TestSaveThenLoad(t *testing.T) {
}
func TestLoadMissing(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
os.RemoveAll("testdir")
_, err := LoadConfigFromDisk("testdir")
require.True(t, os.IsNotExist(err))
}
func TestMergeConfig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
os.RemoveAll("testdir")
err := os.Mkdir("testdir", 0777)
@@ -139,6 +146,8 @@ var expectedMerged = []string{
}
func TestLoadPhonebook(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
os.RemoveAll("testdir")
err := os.Mkdir("testdir", 0777)
require.NoError(t, err)
@@ -156,16 +165,22 @@ func TestLoadPhonebook(t *testing.T) {
}
func TestLoadPhonebookMissing(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
os.RemoveAll("testdir")
_, err := LoadPhonebook("testdir")
require.True(t, os.IsNotExist(err))
}
func TestArchivalIfRelay(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testArchivalIfRelay(t, true)
}
func TestArchivalIfNotRelay(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testArchivalIfRelay(t, false)
}
@@ -203,6 +218,8 @@ func testArchivalIfRelay(t *testing.T, relay bool) {
}
func TestConfigExampleIsCorrect(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ourPath, err := os.Getwd()
@@ -244,6 +261,7 @@ func loadWithoutDefaults(cfg Local) (Local, error) {
}
func TestConfigMigrate(t *testing.T) {
+ partitiontest.PartitionTest(t)
a := require.New(t)
@@ -270,6 +288,8 @@ func TestConfigMigrate(t *testing.T) {
}
func TestConfigMigrateFromDisk(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ourPath, err := os.Getwd()
@@ -291,6 +311,8 @@ func TestConfigMigrateFromDisk(t *testing.T) {
// Verify that nobody is changing the shipping default configurations
func TestConfigInvariant(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ourPath, err := os.Getwd()
@@ -306,6 +328,8 @@ func TestConfigInvariant(t *testing.T) {
}
func TestConfigLatestVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
// Make sure current version is correct for the assigned defaultLocal
@@ -313,6 +337,8 @@ func TestConfigLatestVersion(t *testing.T) {
}
func TestConsensusUpgrades(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
// Starting with v7, ensure we have a path to ConsensusCurrentVersion
@@ -339,6 +365,8 @@ func consensusUpgradesTo(a *require.Assertions, currentName, targetName protocol
}
func TestConsensusLatestVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
latest, has := Consensus[protocol.ConsensusCurrentVersion]
@@ -347,6 +375,8 @@ func TestConsensusLatestVersion(t *testing.T) {
}
func TestLocal_DNSBootstrapArray(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
DNSBootstrapID string
}
@@ -388,6 +418,8 @@ func TestLocal_DNSBootstrapArray(t *testing.T) {
}
func TestLocal_DNSBootstrap(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
DNSBootstrapID string
}
@@ -434,6 +466,8 @@ func TestLocal_DNSBootstrap(t *testing.T) {
}
func TestLocalStructTags(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
localType := reflect.TypeOf(Local{})
versionField, ok := localType.FieldByName("Version")
@@ -475,6 +509,8 @@ func TestLocalStructTags(t *testing.T) {
}
func TestGetVersionedDefaultLocalConfig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for i := uint32(0); i < getLatestConfigVersion(); i++ {
localVersion := getVersionedDefaultLocalConfig(i)
require.Equal(t, uint32(i), localVersion.Version)
@@ -483,6 +519,8 @@ func TestGetVersionedDefaultLocalConfig(t *testing.T) {
// TestLocalVersionField - ensures the Version contains only versions tags, the versions are all contiguous, and that no non-version tags are included there.
func TestLocalVersionField(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
localType := reflect.TypeOf(Local{})
field, ok := localType.FieldByName("Version")
require.True(t, true, ok)
diff --git a/config/consensus.go b/config/consensus.go
index 5bee45ac6..9c7903c0f 100644
--- a/config/consensus.go
+++ b/config/consensus.go
@@ -381,6 +381,8 @@ type ConsensusParams struct {
// 5. checking that in the case of going online the VoteFirst is less or equal to the LastValid+1.
// 6. checking that in the case of going online the VoteFirst is less or equal to the next network round.
EnableKeyregCoherencyCheck bool
+
+ EnableExtraPagesOnAppUpdate bool
}
// PaysetCommitType enumerates possible ways for the block header to commit to
@@ -987,6 +989,9 @@ func initConsensusProtocols() {
// Enable TEAL 5 / AVM 1.0
vFuture.LogicSigVersion = 5
+ // Enable ExtraProgramPages for application update
+ vFuture.EnableExtraPagesOnAppUpdate = true
+
Consensus[protocol.ConsensusFuture] = vFuture
}
diff --git a/config/consensus_test.go b/config/consensus_test.go
index 192717ce1..6cdc2ebd1 100644
--- a/config/consensus_test.go
+++ b/config/consensus_test.go
@@ -19,10 +19,13 @@ package config
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestConsensusParams(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for proto, params := range Consensus {
// Our implementation of Payset.Commit() assumes that
// SupportSignedTxnInBlock implies not PaysetCommitUnsupported.
@@ -39,6 +42,8 @@ func TestConsensusParams(t *testing.T) {
// TestConsensusUpgradeWindow ensures that the upgrade window is a non-zero value, and confirm to be within the valid range.
func TestConsensusUpgradeWindow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for proto, params := range Consensus {
require.GreaterOrEqualf(t, params.MaxUpgradeWaitRounds, params.MinUpgradeWaitRounds, "Version :%v", proto)
for toVersion, delay := range params.ApprovedUpgrades {
diff --git a/config/version.go b/config/version.go
index 6b19636e1..b2d9ca833 100644
--- a/config/version.go
+++ b/config/version.go
@@ -33,7 +33,7 @@ const VersionMajor = 2
// VersionMinor is the Minor semantic version number (x.#.z) - changed when backwards-compatible features are introduced.
// Not enforced until after initial public release (x > 0).
-const VersionMinor = 8
+const VersionMinor = 9
// Version is the type holding our full version information.
type Version struct {
diff --git a/crypto/compactcert/bigfloat_test.go b/crypto/compactcert/bigfloat_test.go
index 78e0fb62b..354821add 100644
--- a/crypto/compactcert/bigfloat_test.go
+++ b/crypto/compactcert/bigfloat_test.go
@@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func rand32() uint32 {
@@ -30,6 +31,8 @@ func rand32() uint32 {
}
func TestBigFloatRounding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := &bigFloatDn{}
b := &bigFloatUp{}
@@ -62,6 +65,8 @@ func TestBigFloatRounding(t *testing.T) {
}
func TestBigFloat(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := &bigFloatDn{}
b := &bigFloatDn{}
diff --git a/crypto/compactcert/builder_test.go b/crypto/compactcert/builder_test.go
index 792744fcc..0bab55da7 100644
--- a/crypto/compactcert/builder_test.go
+++ b/crypto/compactcert/builder_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -51,6 +52,8 @@ func (pc PartCommit) GetHash(pos uint64) (crypto.Digest, error) {
}
func TestBuildVerify(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Doing a full test of 1M accounts takes too much CPU time in CI.
doLargeTest := false
@@ -220,6 +223,8 @@ func BenchmarkBuildVerify(b *testing.B) {
}
func TestCoinIndex(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
n := 1000
b := &Builder{
sigs: make([]sigslot, n),
diff --git a/crypto/compactcert/common_test.go b/crypto/compactcert/common_test.go
index 53f3cfcbd..ce26e4c15 100644
--- a/crypto/compactcert/common_test.go
+++ b/crypto/compactcert/common_test.go
@@ -20,9 +20,12 @@ import (
"testing"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestHashCoin(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var slots [32]uint64
var sigcom [32]byte
var partcom [32]byte
@@ -84,6 +87,8 @@ func BenchmarkHashCoin(b *testing.B) {
}
func TestNumReveals(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
billion := uint64(1000 * 1000 * 1000)
microalgo := uint64(1000 * 1000)
provenWeight := 2 * billion * microalgo
diff --git a/crypto/compactcert/msgp_gen_test.go b/crypto/compactcert/msgp_gen_test.go
index 905370562..5b292879e 100644
--- a/crypto/compactcert/msgp_gen_test.go
+++ b/crypto/compactcert/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Cert{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalCert(b *testing.B) {
}
func TestMarshalUnmarshalCompactOneTimeSignature(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := CompactOneTimeSignature{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalCompactOneTimeSignature(b *testing.B) {
}
func TestMarshalUnmarshalParticipant(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Participant{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalParticipant(b *testing.B) {
}
func TestMarshalUnmarshalReveal(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Reveal{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -248,6 +253,7 @@ func BenchmarkUnmarshalReveal(b *testing.B) {
}
func TestMarshalUnmarshalcoinChoice(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := coinChoice{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -307,6 +313,7 @@ func BenchmarkUnmarshalcoinChoice(b *testing.B) {
}
func TestMarshalUnmarshalsigslotCommit(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := sigslotCommit{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/crypto/merklearray/layer_test.go b/crypto/merklearray/layer_test.go
index 5c4cf7572..96418757f 100644
--- a/crypto/merklearray/layer_test.go
+++ b/crypto/merklearray/layer_test.go
@@ -20,9 +20,12 @@ import (
"testing"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestLayerHash(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var p pair
crypto.RandBytes(p.l[:])
crypto.RandBytes(p.r[:])
diff --git a/crypto/merklearray/merkle_test.go b/crypto/merklearray/merkle_test.go
index 7db789e81..765ce6190 100644
--- a/crypto/merklearray/merkle_test.go
+++ b/crypto/merklearray/merkle_test.go
@@ -22,6 +22,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type TestMessage string
@@ -74,6 +75,8 @@ func (a TestRepeatingArray) GetHash(pos uint64) (crypto.Digest, error) {
}
func TestMerkle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var junk TestData
crypto.RandBytes(junk[:])
diff --git a/crypto/merkletrie/bitset_test.go b/crypto/merkletrie/bitset_test.go
index 983412f79..c722ff453 100644
--- a/crypto/merkletrie/bitset_test.go
+++ b/crypto/merkletrie/bitset_test.go
@@ -20,10 +20,13 @@ import (
"math/bits"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestBitSet(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var a, b bitset
// set the bits in a different order, and see if we're ending with the same set.
@@ -63,6 +66,8 @@ func TestBitSet(t *testing.T) {
// TestBitSetOneBit test that only one bit is being set when we call SetBit
func TestBitSetOneBit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for i := 0; i < 256; i++ {
var a bitset
a.SetBit(byte(i))
diff --git a/crypto/merkletrie/cache_test.go b/crypto/merkletrie/cache_test.go
index 9d35f92aa..07819644e 100644
--- a/crypto/merkletrie/cache_test.go
+++ b/crypto/merkletrie/cache_test.go
@@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var defaultTestMemoryConfig = MemoryConfig{
@@ -50,6 +51,8 @@ func verifyCacheNodeCount(t *testing.T, trie *Trie) {
}
func TestCacheEviction1(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter, defaultTestMemoryConfig)
// create 13000 hashes.
@@ -72,6 +75,8 @@ func TestCacheEviction1(t *testing.T) {
}
func TestCacheEviction2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter, defaultTestMemoryConfig)
// create 20000 hashes.
@@ -99,6 +104,8 @@ func TestCacheEviction2(t *testing.T) {
}
func TestCacheEviction3(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter, defaultTestMemoryConfig)
// create 200000 hashes.
@@ -185,6 +192,8 @@ func cacheEvictionFuzzer(t *testing.T, hashes []crypto.Digest, pageSize int64, e
// TestCacheEvictionFuzzer generates bursts of random Add/Delete operations on the trie, and
// testing the correctness of the cache internal buffers priodically.
func TestCacheEvictionFuzzer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// create 2000 hashes.
leafsCount := 2000
hashes := make([]crypto.Digest, leafsCount)
@@ -203,6 +212,8 @@ func TestCacheEvictionFuzzer(t *testing.T) {
// TestCacheEvictionFuzzer generates bursts of random Add/Delete operations on the trie, and
// testing the correctness of the cache internal buffers priodically.
func TestCacheEvictionFuzzer2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// create 1000 hashes.
leafsCount := 1000
hashes := make([]crypto.Digest, leafsCount)
@@ -223,6 +234,8 @@ func TestCacheEvictionFuzzer2(t *testing.T) {
// delete a in-memory page during merkleTrieCache.commitTransaction(),
// it's being deleted correctly.
func TestCacheMidTransactionPageDeletion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter smallPageMemoryCommitter
memoryConfig := defaultTestMemoryConfig
memoryConfig.NodesCountPerPage = 2
@@ -308,6 +321,8 @@ func (mt *Trie) TestDeleteRollback(d []byte) (bool, error) {
// delete a in-memory page during merkleTrieCache.rollbackTransaction(),
// it's being deleted correctly.
func TestCacheTransactionRollbackPageDeletion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter smallPageMemoryCommitter
memConfig := defaultTestMemoryConfig
memConfig.CachedNodesCount = 5
@@ -349,6 +364,8 @@ func TestCacheTransactionRollbackPageDeletion(t *testing.T) {
// delete a in-memory page during merkleTrieCache.deleteNode(),
// it's being deleted correctly.
func TestCacheDeleteNodeMidTransaction(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter smallPageMemoryCommitter
memConfig := defaultTestMemoryConfig
memConfig.CachedNodesCount = 5
@@ -382,6 +399,8 @@ func TestCacheDeleteNodeMidTransaction(t *testing.T) {
// TestCachePageLoading ensures that during page loading, the number of cachedNodeCount is not
// increased if the page was already loaded previously into memory.
func TestCachePageReloading(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter, defaultTestMemoryConfig)
// create 10 hashes.
@@ -422,6 +441,8 @@ func TestCachePageReloading(t *testing.T) {
// TestCachePagedOutTip verifies that the evict function would prioritize
// evicting other pages before evicting the top page.
func TestCachePagedOutTip(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
memConfig := defaultTestMemoryConfig
memConfig.CachedNodesCount = 600
@@ -458,6 +479,8 @@ func TestCachePagedOutTip(t *testing.T) {
// TestCacheLoadingDeferedPage verifies that the loadPage
// method correcly resets the mtc.deferedPageLoad on the correct page.
func TestCacheLoadingDeferedPage(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter1 InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter1, defaultTestMemoryConfig)
// create 100000 hashes.
diff --git a/crypto/merkletrie/committer_test.go b/crypto/merkletrie/committer_test.go
index c82a6f915..04a43a1b2 100644
--- a/crypto/merkletrie/committer_test.go
+++ b/crypto/merkletrie/committer_test.go
@@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// Duplicate duplicates the current memory committer.
@@ -41,6 +42,8 @@ func (mc *InMemoryCommitter) Duplicate(flat bool) (out *InMemoryCommitter) {
}
func TestInMemoryCommitter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter, defaultTestMemoryConfig)
// create 50000 hashes.
@@ -101,6 +104,8 @@ func (n *node) getChildren() (list []storedNodeIdentifier) {
}
func TestNoRedundentPages(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
mt1, _ := MakeTrie(&memoryCommitter, defaultTestMemoryConfig)
@@ -152,6 +157,8 @@ func decodePageHeaderSize(bytes []byte) (headerSize int, err error) {
}
func TestMultipleCommits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testSize := 5000
commitsCount := 5
@@ -195,6 +202,8 @@ func TestMultipleCommits(t *testing.T) {
}
func TestIterativeCommits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testSize := 1000
memConfig := MemoryConfig{
diff --git a/crypto/merkletrie/node_test.go b/crypto/merkletrie/node_test.go
index 34beddcaf..db4f02bdf 100644
--- a/crypto/merkletrie/node_test.go
+++ b/crypto/merkletrie/node_test.go
@@ -22,10 +22,13 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// TestNodeSerialization tests the serialization and deserialization of nodes.
func TestNodeSerialization(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var memoryCommitter InMemoryCommitter
memConfig := defaultTestMemoryConfig
memConfig.CachedNodesCount = 1000
diff --git a/crypto/merkletrie/trie_test.go b/crypto/merkletrie/trie_test.go
index 120ac9ed3..82f86b2d1 100644
--- a/crypto/merkletrie/trie_test.go
+++ b/crypto/merkletrie/trie_test.go
@@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
const (
@@ -30,6 +31,8 @@ const (
)
func TestAddingAndRemoving(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
mt, _ := MakeTrie(nil, defaultTestMemoryConfig)
// create 10000 hashes.
hashes := make([]crypto.Digest, 10000)
@@ -82,6 +85,8 @@ func TestAddingAndRemoving(t *testing.T) {
}
func TestRandomAddingAndRemoving(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
mt, err := MakeTrie(nil, defaultTestMemoryConfig)
require.NoError(t, err)
diff --git a/crypto/msgp_gen_test.go b/crypto/msgp_gen_test.go
index b06861341..8a80c972f 100644
--- a/crypto/msgp_gen_test.go
+++ b/crypto/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalDigest(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Digest{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalDigest(b *testing.B) {
}
func TestMarshalUnmarshalMasterDerivationKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := MasterDerivationKey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalMasterDerivationKey(b *testing.B) {
}
func TestMarshalUnmarshalMultisigSig(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := MultisigSig{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalMultisigSig(b *testing.B) {
}
func TestMarshalUnmarshalMultisigSubsig(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := MultisigSubsig{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -248,6 +253,7 @@ func BenchmarkUnmarshalMultisigSubsig(b *testing.B) {
}
func TestMarshalUnmarshalOneTimeSignature(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := OneTimeSignature{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -307,6 +313,7 @@ func BenchmarkUnmarshalOneTimeSignature(b *testing.B) {
}
func TestMarshalUnmarshalOneTimeSignatureSecrets(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := OneTimeSignatureSecrets{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -366,6 +373,7 @@ func BenchmarkUnmarshalOneTimeSignatureSecrets(b *testing.B) {
}
func TestMarshalUnmarshalOneTimeSignatureSecretsPersistent(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := OneTimeSignatureSecretsPersistent{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -425,6 +433,7 @@ func BenchmarkUnmarshalOneTimeSignatureSecretsPersistent(b *testing.B) {
}
func TestMarshalUnmarshalOneTimeSignatureSubkeyBatchID(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := OneTimeSignatureSubkeyBatchID{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -484,6 +493,7 @@ func BenchmarkUnmarshalOneTimeSignatureSubkeyBatchID(b *testing.B) {
}
func TestMarshalUnmarshalOneTimeSignatureSubkeyOffsetID(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := OneTimeSignatureSubkeyOffsetID{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -543,6 +553,7 @@ func BenchmarkUnmarshalOneTimeSignatureSubkeyOffsetID(b *testing.B) {
}
func TestMarshalUnmarshalOneTimeSignatureVerifier(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := OneTimeSignatureVerifier{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -602,6 +613,7 @@ func BenchmarkUnmarshalOneTimeSignatureVerifier(b *testing.B) {
}
func TestMarshalUnmarshalPrivateKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := PrivateKey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -661,6 +673,7 @@ func BenchmarkUnmarshalPrivateKey(b *testing.B) {
}
func TestMarshalUnmarshalPublicKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := PublicKey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -720,6 +733,7 @@ func BenchmarkUnmarshalPublicKey(b *testing.B) {
}
func TestMarshalUnmarshalSeed(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Seed{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -779,6 +793,7 @@ func BenchmarkUnmarshalSeed(b *testing.B) {
}
func TestMarshalUnmarshalSignature(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Signature{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -838,6 +853,7 @@ func BenchmarkUnmarshalSignature(b *testing.B) {
}
func TestMarshalUnmarshalSignatureSecrets(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := SignatureSecrets{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -897,6 +913,7 @@ func BenchmarkUnmarshalSignatureSecrets(b *testing.B) {
}
func TestMarshalUnmarshalVRFSecrets(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := VRFSecrets{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -956,6 +973,7 @@ func BenchmarkUnmarshalVRFSecrets(b *testing.B) {
}
func TestMarshalUnmarshalVrfOutput(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := VrfOutput{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1015,6 +1033,7 @@ func BenchmarkUnmarshalVrfOutput(b *testing.B) {
}
func TestMarshalUnmarshalVrfPrivkey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := VrfPrivkey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1074,6 +1093,7 @@ func BenchmarkUnmarshalVrfPrivkey(b *testing.B) {
}
func TestMarshalUnmarshalVrfProof(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := VrfProof{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1133,6 +1153,7 @@ func BenchmarkUnmarshalVrfProof(b *testing.B) {
}
func TestMarshalUnmarshalVrfPubkey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := VrfPubkey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1192,6 +1213,7 @@ func BenchmarkUnmarshalVrfPubkey(b *testing.B) {
}
func TestMarshalUnmarshaled25519PrivateKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ed25519PrivateKey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1251,6 +1273,7 @@ func BenchmarkUnmarshaled25519PrivateKey(b *testing.B) {
}
func TestMarshalUnmarshaled25519PublicKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ed25519PublicKey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1310,6 +1333,7 @@ func BenchmarkUnmarshaled25519PublicKey(b *testing.B) {
}
func TestMarshalUnmarshaled25519Seed(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ed25519Seed{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1369,6 +1393,7 @@ func BenchmarkUnmarshaled25519Seed(b *testing.B) {
}
func TestMarshalUnmarshaled25519Signature(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ed25519Signature{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -1428,6 +1453,7 @@ func BenchmarkUnmarshaled25519Signature(b *testing.B) {
}
func TestMarshalUnmarshalephemeralSubkey(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ephemeralSubkey{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/crypto/passphrase/passphrase_test.go b/crypto/passphrase/passphrase_test.go
index 46c88b876..fc4b399d1 100644
--- a/crypto/passphrase/passphrase_test.go
+++ b/crypto/passphrase/passphrase_test.go
@@ -24,9 +24,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestGenerateAndRecovery(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
key := make([]byte, 32)
for i := 0; i < 1000; i++ {
// Generate a key
@@ -42,6 +45,8 @@ func TestGenerateAndRecovery(t *testing.T) {
}
func TestZeroVector(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
zeroVector := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
mn := "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon invest"
@@ -52,6 +57,8 @@ func TestZeroVector(t *testing.T) {
}
func TestWordNotInList(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
mn := "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon zzz invest"
_, err := MnemonicToKey(mn)
require.Error(t, err)
@@ -59,6 +66,8 @@ func TestWordNotInList(t *testing.T) {
}
func TestCorruptedChecksum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
key := make([]byte, 32)
_, err := rand.Read(key)
require.NoError(t, err)
@@ -73,6 +82,8 @@ func TestCorruptedChecksum(t *testing.T) {
}
func TestInvalidKeyLen(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
badLens := []int{0, 31, 33, 100}
for _, l := range badLens {
key := make([]byte, l)
@@ -85,6 +96,8 @@ func TestInvalidKeyLen(t *testing.T) {
}
func TestUint11Array(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
N := 11*8*32 + 1
for i := 0; i < N; i++ {
diff --git a/daemon/algod/api/server/router_test.go b/daemon/algod/api/server/router_test.go
index 0e180d9f2..3c0d8295a 100644
--- a/daemon/algod/api/server/router_test.go
+++ b/daemon/algod/api/server/router_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/daemon/algod/api/server/lib"
"github.com/algorand/go-algorand/daemon/algod/api/server/v1/routes"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type TestSuite struct {
@@ -55,12 +56,14 @@ func (s *TestSuite) SetupTest() {
s.calls = 0
}
func (s *TestSuite) TestBaselineRoute() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v0/this/is/no/endpoint", ctx)
assert.Equal(s.T(), echo.ErrNotFound, ctx.Handler()(ctx))
assert.Equal(s.T(), 0, s.calls)
}
func (s *TestSuite) TestAccountPendingTransaction() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/account/address-param/transactions/pending", ctx)
assert.Equal(s.T(), "/v1/account/:addr/transactions/pending", ctx.Path())
@@ -72,6 +75,7 @@ func (s *TestSuite) TestAccountPendingTransaction() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestWaitAfterBlock() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/status/wait-for-block-after/123456", ctx)
assert.Equal(s.T(), "/v1/status/wait-for-block-after/:round", ctx.Path())
@@ -83,6 +87,7 @@ func (s *TestSuite) TestWaitAfterBlock() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestAccountInformation() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/account/ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA", ctx)
assert.Equal(s.T(), "/v1/account/:addr", ctx.Path())
@@ -94,6 +99,7 @@ func (s *TestSuite) TestAccountInformation() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestTransactionInformation() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
addr := "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA"
txid := "ASPB5E72OT2UWSOCQGD5OPT3W4KV4LZZDL7L5MBCC3EBAIJCDHAA"
@@ -108,6 +114,7 @@ func (s *TestSuite) TestTransactionInformation() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestAccountTransaction() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
addr := "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA"
s.e.Router().Find(http.MethodGet, "/v1/account/"+addr+"/transactions", ctx)
@@ -120,6 +127,7 @@ func (s *TestSuite) TestAccountTransaction() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestBlock() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/block/123456", ctx)
assert.Equal(s.T(), "/v1/block/:round", ctx.Path())
@@ -131,6 +139,7 @@ func (s *TestSuite) TestBlock() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestPendingTransactionID() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
txid := "ASPB5E72OT2UWSOCQGD5OPT3W4KV4LZZDL7L5MBCC3EBAIJCDHAA"
s.e.Router().Find(http.MethodGet, "/v1/transactions/pending/"+txid, ctx)
@@ -143,6 +152,7 @@ func (s *TestSuite) TestPendingTransactionID() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestPendingTransactionInformationByAddress() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
addr := "ZBBRQD73JH5KZ7XRED6GALJYJUXOMBBP3X2Z2XFA4LATV3MUJKKMKG7SHA"
s.e.Router().Find(http.MethodGet, "/v1/account/"+addr+"/transactions/pending", ctx)
@@ -155,6 +165,7 @@ func (s *TestSuite) TestPendingTransactionInformationByAddress() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestGetAsset() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
s.e.Router().Find(http.MethodGet, "/v1/asset/123456", ctx)
assert.Equal(s.T(), "/v1/asset/:index", ctx.Path())
@@ -166,6 +177,7 @@ func (s *TestSuite) TestGetAsset() {
assert.Equal(s.T(), callsBefore+1, s.calls)
}
func (s *TestSuite) TestGetTransactionByID() {
+ partitiontest.PartitionTest(s.T())
ctx := s.e.NewContext(nil, nil)
txid := "ASPB5E72OT2UWSOCQGD5OPT3W4KV4LZZDL7L5MBCC3EBAIJCDHAA"
s.e.Router().Find(http.MethodGet, "/v1/transaction/"+txid, ctx)
diff --git a/daemon/algod/api/server/v2/handlers.go b/daemon/algod/api/server/v2/handlers.go
index 7a74c6b2a..070baff87 100644
--- a/daemon/algod/api/server/v2/handlers.go
+++ b/daemon/algod/api/server/v2/handlers.go
@@ -393,7 +393,7 @@ func (v2 *Handlers) TealDryrun(ctx echo.Context) error {
var dr DryrunRequest
var gdr generated.DryrunRequest
- err := decode(protocol.JSONHandle, data, &gdr)
+ err := decode(protocol.JSONStrictHandle, data, &gdr)
if err == nil {
dr, err = DryrunRequestFromGenerated(&gdr)
if err != nil {
diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go
index da98d6549..b5930e28a 100644
--- a/daemon/algod/api/server/v2/test/handlers_test.go
+++ b/daemon/algod/api/server/v2/test/handlers_test.go
@@ -18,6 +18,7 @@ package test
import (
"bytes"
+ "encoding/json"
"errors"
"io"
"net/http"
@@ -27,16 +28,20 @@ import (
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/require"
+ "github.com/algorand/go-algorand/agreement"
+ "github.com/algorand/go-algorand/crypto"
v2 "github.com/algorand/go-algorand/daemon/algod/api/server/v2"
"github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated"
generatedV2 "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated"
"github.com/algorand/go-algorand/data/account"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/node"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/util/execpool"
)
func setupTestForMethodGet(t *testing.T) (v2.Handlers, echo.Context, *httptest.ResponseRecorder, []account.Root, []transactions.SignedTxn, func()) {
@@ -105,6 +110,101 @@ func TestGetBlock(t *testing.T) {
getBlockTest(t, 0, "bad format", 400)
}
+func TestGetBlockJsonEncoding(t *testing.T) {
+ t.Parallel()
+
+ handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t)
+ defer releasefunc()
+
+ l := handler.Node.Ledger()
+
+ genBlk, err := l.Block(0)
+ require.NoError(t, err)
+
+ // make an app call txn with eval delta
+ lsig := transactions.LogicSig{Logic: retOneProgram} // int 1
+ program := logic.Program(lsig.Logic)
+ lhash := crypto.HashObj(&program)
+ var sender basics.Address
+ copy(sender[:], lhash[:])
+ stx := transactions.SignedTxn{
+ Txn: transactions.Transaction{
+ Type: protocol.ApplicationCallTx,
+ Header: transactions.Header{
+ Sender: sender,
+ Fee: basics.MicroAlgos{Raw: 1000},
+ GenesisID: genBlk.GenesisID(),
+ GenesisHash: genBlk.GenesisHash(),
+ FirstValid: 1,
+ LastValid: 10,
+ },
+ ApplicationCallTxnFields: transactions.ApplicationCallTxnFields{
+ ApplicationID: 1,
+ OnCompletion: transactions.ClearStateOC,
+ },
+ },
+ Lsig: lsig,
+ }
+ ad := transactions.ApplyData{
+ EvalDelta: basics.EvalDelta{
+ LocalDeltas: map[uint64]basics.StateDelta{
+ 1: {"key": basics.ValueDelta{Action: 1}},
+ },
+ },
+ }
+
+ // put it into a block
+ backlogPool := execpool.MakeBacklog(nil, 0, execpool.LowPriority, nil)
+ defer backlogPool.Shutdown()
+
+ totals, err := l.Totals(l.Latest())
+ require.NoError(t, err)
+ totalRewardUnits := totals.RewardUnits()
+ poolBal, err := l.Lookup(l.Latest(), poolAddr)
+ require.NoError(t, err)
+
+ var blk bookkeeping.Block
+ blk.BlockHeader = bookkeeping.BlockHeader{
+ GenesisID: genBlk.GenesisID(),
+ GenesisHash: genBlk.GenesisHash(),
+ Round: l.Latest() + 1,
+ Branch: genBlk.Hash(),
+ TimeStamp: 0,
+ RewardsState: genBlk.NextRewardsState(l.Latest()+1, proto, poolBal.MicroAlgos, totalRewardUnits),
+ UpgradeState: genBlk.UpgradeState,
+ }
+
+ blk.BlockHeader.TxnCounter = genBlk.TxnCounter
+
+ blk.RewardsPool = genBlk.RewardsPool
+ blk.FeeSink = genBlk.FeeSink
+ blk.CurrentProtocol = genBlk.CurrentProtocol
+ blk.TimeStamp = genBlk.TimeStamp + 1
+
+ txib, err := blk.EncodeSignedTxn(stx, ad)
+ blk.Payset = append(blk.Payset, txib)
+ blk.BlockHeader.TxnCounter++
+ blk.TxnRoot, err = blk.PaysetCommit()
+ require.NoError(t, err)
+
+ err = l.AddBlock(blk, agreement.Certificate{})
+ require.NoError(t, err)
+
+ // fetch the block and ensure it can be properly decoded with the standard JSON decoder
+ format := "json"
+ err = handler.GetBlock(c, 1, generatedV2.GetBlockParams{Format: &format})
+ require.NoError(t, err)
+ require.Equal(t, 200, rec.Code)
+ data := rec.Body.Bytes()
+
+ response := struct {
+ Block bookkeeping.Block `codec:"block"`
+ }{}
+
+ err = json.Unmarshal(data, &response)
+ require.NoError(t, err)
+}
+
func TestGetSupply(t *testing.T) {
t.Parallel()
diff --git a/daemon/algod/api/server/v2/test/helpers.go b/daemon/algod/api/server/v2/test/helpers.go
index b5962cf4c..28d35c857 100644
--- a/daemon/algod/api/server/v2/test/helpers.go
+++ b/daemon/algod/api/server/v2/test/helpers.go
@@ -32,6 +32,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
+ "github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/node"
@@ -188,6 +189,7 @@ var sinkAddr = basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb
var poolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
var genesisHash = crypto.Digest{0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}
var genesisID = "testingid"
+var retOneProgram = []byte{2, 0x20, 1, 1, 0x22}
var proto = config.Consensus[protocol.ConsensusCurrentVersion]
@@ -256,7 +258,15 @@ func testingenv(t testing.TB, numAccounts, numTxs int, offlineAccounts bool) (*d
genesis[poolAddr] = basics.MakeAccountData(basics.NotParticipating, basics.MicroAlgos{Raw: 100000 * uint64(proto.RewardsRateRefreshInterval)})
- bootstrap := data.MakeGenesisBalances(genesis, poolAddr, sinkAddr)
+ program := logic.Program(retOneProgram)
+ lhash := crypto.HashObj(&program)
+ var addr basics.Address
+ copy(addr[:], lhash[:])
+ ad := basics.MakeAccountData(basics.NotParticipating, basics.MicroAlgos{Raw: 100000 * uint64(proto.RewardsRateRefreshInterval)})
+ ad.AppLocalStates = map[basics.AppIndex]basics.AppLocalState{1: {}}
+ genesis[addr] = ad
+
+ bootstrap := data.MakeGenesisBalances(genesis, sinkAddr, poolAddr)
// generate test transactions
const inMem = true
diff --git a/daemon/algod/api/server/v2/utils.go b/daemon/algod/api/server/v2/utils.go
index 678889062..e4b2dd24c 100644
--- a/daemon/algod/api/server/v2/utils.go
+++ b/daemon/algod/api/server/v2/utils.go
@@ -186,7 +186,7 @@ func getCodecHandle(formatPtr *string) (codec.Handle, string, error) {
switch format {
case "json":
- return protocol.JSONHandle, "application/json", nil
+ return protocol.JSONStrictHandle, "application/json", nil
case "msgpack":
fallthrough
case "msgp":
diff --git a/daemon/algod/deadlock_test.go b/daemon/algod/deadlock_test.go
index 8df0baec5..1df1594e0 100644
--- a/daemon/algod/deadlock_test.go
+++ b/daemon/algod/deadlock_test.go
@@ -25,9 +25,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestDeadlockLogging(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
logFn := fmt.Sprintf("/tmp/test.%s.%d.log", t.Name(), crypto.RandUint64())
archiveFn := fmt.Sprintf("%s.archive", logFn)
@@ -57,6 +60,8 @@ func TestDeadlockLogging(t *testing.T) {
}
func TestDeadlockOnPotentialDeadlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
logFn := fmt.Sprintf("/tmp/test.%s.%d.log", t.Name(), crypto.RandUint64())
archiveFn := fmt.Sprintf("%s.archive", logFn)
diff --git a/daemon/algod/server_test.go b/daemon/algod/server_test.go
index ca7784604..d4a6a26ee 100644
--- a/daemon/algod/server_test.go
+++ b/daemon/algod/server_test.go
@@ -23,6 +23,7 @@ import (
"net"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -34,6 +35,8 @@ func isTCPPortAvailable(host string, port int) bool {
return err == nil
}
func TestFirstListenerSetupGetsPort8080WhenPassedPortZero(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// this test will fail if there is already a listener on the testing machine's port 8080
// (except if a dev has a node running on port 8080 and runs the test; in that case, we can't run this test.)
targetPort := 8080
@@ -51,6 +54,8 @@ func TestFirstListenerSetupGetsPort8080WhenPassedPortZero(t *testing.T) {
}
func TestSecondListenerSetupGetsAnotherPortWhen8080IsBusy(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
defaultAddr := "127.0.0.1:0"
unexpectedAddr := "127.0.0.1:8080"
makeListener(defaultAddr)
@@ -61,6 +66,8 @@ func TestSecondListenerSetupGetsAnotherPortWhen8080IsBusy(t *testing.T) {
}
func TestFirstListenerSetupGetsPassedPortWhenPassedPortNonZero(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
expectedAddr := "127.0.0.1:8081"
listener, err := makeListener(expectedAddr)
require.NoError(t, err)
diff --git a/daemon/kmd/config/config.go b/daemon/kmd/config/config.go
index f4c70c5a3..39827f2c7 100644
--- a/daemon/kmd/config/config.go
+++ b/daemon/kmd/config/config.go
@@ -45,6 +45,7 @@ type KMDConfig struct {
// DriverConfig contains config info specific to each wallet driver
type DriverConfig struct {
SQLiteWalletDriverConfig SQLiteWalletDriverConfig `json:"sqlite"`
+ LedgerWalletDriverConfig LedgerWalletDriverConfig `json:"ledger"`
}
// SQLiteWalletDriverConfig is configuration specific to the SQLiteWalletDriver
@@ -54,6 +55,11 @@ type SQLiteWalletDriverConfig struct {
ScryptParams ScryptParams `json:"scrypt"`
}
+// LedgerWalletDriverConfig is configuration specific to the LedgerWalletDriver
+type LedgerWalletDriverConfig struct {
+ Disable bool `json:"disable"`
+}
+
// ScryptParams stores the parameters used for key derivation. This allows
// upgrading security parameters over time
type ScryptParams struct {
diff --git a/daemon/kmd/wallet/driver/ledger.go b/daemon/kmd/wallet/driver/ledger.go
index 9c9432cae..7affe3a5c 100644
--- a/daemon/kmd/wallet/driver/ledger.go
+++ b/daemon/kmd/wallet/driver/ledger.go
@@ -22,6 +22,7 @@ import (
"encoding/binary"
"errors"
"fmt"
+ "os"
"sort"
"strings"
@@ -61,6 +62,7 @@ type LedgerWalletDriver struct {
mu deadlock.Mutex
wallets map[string]*LedgerWallet
log logging.Logger
+ cfg config.LedgerWalletDriverConfig
}
// LedgerWallet represents a particular wallet under the
@@ -97,11 +99,20 @@ func (lwd *LedgerWalletDriver) FetchWallet(id []byte) (w wallet.Wallet, err erro
// scanWalletsLocked enumerates attached ledger devices and stores them.
// lwd.mu must be held
func (lwd *LedgerWalletDriver) scanWalletsLocked() error {
+
+ if os.Getenv("KMD_NOUSB") != "" {
+ return nil
+ }
+
// Initialize wallets map
if lwd.wallets == nil {
lwd.wallets = make(map[string]*LedgerWallet)
}
+ if lwd.cfg.Disable {
+ return nil
+ }
+
// Enumerate attached wallet devices
infos, err := LedgerEnumerate()
if err != nil {
@@ -173,6 +184,8 @@ func (lwd *LedgerWalletDriver) InitWithConfig(cfg config.KMDConfig, log logging.
defer lwd.mu.Unlock()
lwd.log = log
+ lwd.cfg = cfg.DriverConfig.LedgerWalletDriverConfig
+
return lwd.scanWalletsLocked()
}
diff --git a/daemon/kmd/wallet/driver/ledger_hid.go b/daemon/kmd/wallet/driver/ledger_hid.go
index d31bd7b2e..22a8e05ac 100644
--- a/daemon/kmd/wallet/driver/ledger_hid.go
+++ b/daemon/kmd/wallet/driver/ledger_hid.go
@@ -19,6 +19,7 @@ package driver
import (
"encoding/binary"
"fmt"
+ "os"
"github.com/karalabe/hid"
)
@@ -196,7 +197,7 @@ func (l *LedgerUSB) USBInfo() hid.DeviceInfo {
// LedgerEnumerate returns all of the Ledger devices connected to this machine.
func LedgerEnumerate() ([]hid.DeviceInfo, error) {
- if !hid.Supported() {
+ if !hid.Supported() || os.Getenv("KMD_NOUSB") != "" {
return nil, fmt.Errorf("HID not supported")
}
diff --git a/data/account/participation_test.go b/data/account/participation_test.go
index d80155d84..b92929b36 100644
--- a/data/account/participation_test.go
+++ b/data/account/participation_test.go
@@ -28,10 +28,13 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
func TestParticipation_NewDB(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
rootDB, err := db.MakeAccessor(t.Name(), false, true)
@@ -86,6 +89,8 @@ func getSchemaVersions(db db.Accessor) (versions map[string]int, err error) {
}
func TestOverlapsInterval(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const before = basics.Round(95)
const start = basics.Round(100)
const middle = basics.Round(105)
diff --git a/data/basics/address_test.go b/data/basics/address_test.go
index 14d40ab0f..f99f3392d 100644
--- a/data/basics/address_test.go
+++ b/data/basics/address_test.go
@@ -23,9 +23,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestChecksumAddress_Unmarshal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
address := crypto.Hash([]byte("randomString"))
shortAddress := Address(address)
@@ -37,6 +40,8 @@ func TestChecksumAddress_Unmarshal(t *testing.T) {
}
func TestAddressChecksumMalformedWrongChecksum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
address := crypto.Hash([]byte("randomString"))
shortAddress := Address(address)
@@ -47,12 +52,16 @@ func TestAddressChecksumMalformedWrongChecksum(t *testing.T) {
}
func TestAddressChecksumShort(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var address string
_, err := UnmarshalChecksumAddress(address)
require.NotNil(t, err)
}
func TestAddressChecksumMalformedWrongChecksumSpace(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
address := crypto.Hash([]byte("randomString"))
shortAddress := Address(address)
@@ -63,6 +72,8 @@ func TestAddressChecksumMalformedWrongChecksumSpace(t *testing.T) {
}
func TestAddressChecksumMalformedWrongAddress(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
address := crypto.Hash([]byte("randomString"))
shortAddress := Address(address)
@@ -73,6 +84,8 @@ func TestAddressChecksumMalformedWrongAddress(t *testing.T) {
}
func TestAddressChecksumMalformedWrongAddressSpaces(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
address := crypto.Hash([]byte("randomString"))
shortAddress := Address(address)
@@ -83,6 +96,8 @@ func TestAddressChecksumMalformedWrongAddressSpaces(t *testing.T) {
}
func TestAddressChecksumCanonical(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
addr := "J5YDZLPOHWB5O6MVRHNFGY4JXIQAYYM6NUJWPBSYBBIXH5ENQ4Z5LTJELU"
nonCanonical := "J5YDZLPOHWB5O6MVRHNFGY4JXIQAYYM6NUJWPBSYBBIXH5ENQ4Z5LTJELV"
@@ -98,6 +113,8 @@ type TestOb struct {
}
func TestAddressMarshalUnmarshal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var addr Address
crypto.RandBytes(addr[:])
testob := TestOb{Aaaa: addr}
diff --git a/data/basics/msgp_gen_test.go b/data/basics/msgp_gen_test.go
index f26f90aac..558e1c091 100644
--- a/data/basics/msgp_gen_test.go
+++ b/data/basics/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalAccountData(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AccountData{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalAccountData(b *testing.B) {
}
func TestMarshalUnmarshalAppLocalState(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AppLocalState{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalAppLocalState(b *testing.B) {
}
func TestMarshalUnmarshalAppParams(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AppParams{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalAppParams(b *testing.B) {
}
func TestMarshalUnmarshalAssetHolding(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AssetHolding{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -248,6 +253,7 @@ func BenchmarkUnmarshalAssetHolding(b *testing.B) {
}
func TestMarshalUnmarshalAssetParams(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AssetParams{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -307,6 +313,7 @@ func BenchmarkUnmarshalAssetParams(b *testing.B) {
}
func TestMarshalUnmarshalBalanceRecord(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := BalanceRecord{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -366,6 +373,7 @@ func BenchmarkUnmarshalBalanceRecord(b *testing.B) {
}
func TestMarshalUnmarshalEvalDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := EvalDelta{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -425,6 +433,7 @@ func BenchmarkUnmarshalEvalDelta(b *testing.B) {
}
func TestMarshalUnmarshalStateDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := StateDelta{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -484,6 +493,7 @@ func BenchmarkUnmarshalStateDelta(b *testing.B) {
}
func TestMarshalUnmarshalStateSchema(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := StateSchema{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -543,6 +553,7 @@ func BenchmarkUnmarshalStateSchema(b *testing.B) {
}
func TestMarshalUnmarshalStateSchemas(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := StateSchemas{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -602,6 +613,7 @@ func BenchmarkUnmarshalStateSchemas(b *testing.B) {
}
func TestMarshalUnmarshalTealKeyValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := TealKeyValue{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -661,6 +673,7 @@ func BenchmarkUnmarshalTealKeyValue(b *testing.B) {
}
func TestMarshalUnmarshalTealValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := TealValue{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -720,6 +733,7 @@ func BenchmarkUnmarshalTealValue(b *testing.B) {
}
func TestMarshalUnmarshalValueDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ValueDelta{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/data/basics/teal_test.go b/data/basics/teal_test.go
index f47616331..35b4331e8 100644
--- a/data/basics/teal_test.go
+++ b/data/basics/teal_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestStateDeltaValid(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
// test pre-applications proto
@@ -82,6 +85,8 @@ func TestStateDeltaValid(t *testing.T) {
}
func TestStateDeltaValidV24(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
// v24: short key, value too long: hits MaxAppBytesValueLen
@@ -103,6 +108,8 @@ func TestStateDeltaValidV24(t *testing.T) {
}
func TestStateDeltaEqual(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var d1 StateDelta = nil
@@ -138,6 +145,8 @@ func TestStateDeltaEqual(t *testing.T) {
}
func TestEvalDeltaEqual(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
d1 := EvalDelta{}
diff --git a/data/basics/units_test.go b/data/basics/units_test.go
index 74e69c82e..6ef8ba43e 100644
--- a/data/basics/units_test.go
+++ b/data/basics/units_test.go
@@ -19,10 +19,13 @@ package basics
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestSubSaturate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := Round(1)
b := Round(2)
require.Equal(t, a.SubSaturate(b), Round(0))
@@ -31,6 +34,8 @@ func TestSubSaturate(t *testing.T) {
}
func TestRoundUpToMultipleOf(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
r := Round(24)
for n := Round(1); n < Round(100); n++ {
nextMul := r.RoundUpToMultipleOf(n)
diff --git a/data/basics/userBalance_test.go b/data/basics/userBalance_test.go
index 27558ba9a..89b490107 100644
--- a/data/basics/userBalance_test.go
+++ b/data/basics/userBalance_test.go
@@ -26,14 +26,19 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestEmptyEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var ub BalanceRecord
require.Equal(t, 1, len(protocol.Encode(&ub)))
}
func TestRewards(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
accountAlgos := []MicroAlgos{{Raw: 0}, {Raw: 8000}, {Raw: 13000}, {Raw: 83000}}
for _, accountAlgo := range accountAlgos {
@@ -54,6 +59,8 @@ func TestRewards(t *testing.T) {
}
func TestWithUpdatedRewardsPanics(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
t.Run("AlgoPanic", func(t *testing.T) {
paniced := false
@@ -99,6 +106,8 @@ func makeString(len int) string {
}
func TestEncodedAccountDataSize(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
oneTimeSecrets := crypto.GenerateOneTimeSignatureSecrets(0, 1)
vrfSecrets := crypto.GenerateVRFSecrets()
maxStateSchema := StateSchema{
@@ -203,6 +212,8 @@ func TestEncodedAccountDataSize(t *testing.T) {
}
func TestEncodedAccountAllocationBounds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// ensure that all the supported protocols have value limits less or
// equal to their corresponding codec allocbounds
for protoVer, proto := range config.Consensus {
diff --git a/data/bookkeeping/block_test.go b/data/bookkeeping/block_test.go
index 4bce02f71..671905594 100644
--- a/data/bookkeeping/block_test.go
+++ b/data/bookkeeping/block_test.go
@@ -27,6 +27,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var delegatesMoney = basics.MicroAlgos{Raw: 1000 * 1000 * 1000}
@@ -60,6 +61,8 @@ func init() {
}
func TestUpgradeVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
s := UpgradeState{
CurrentProtocol: proto1,
}
@@ -121,6 +124,8 @@ func TestUpgradeVote(t *testing.T) {
}
func TestUpgradeVariableDelay(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
s := UpgradeState{
CurrentProtocol: protoDelay,
}
@@ -145,6 +150,8 @@ func TestUpgradeVariableDelay(t *testing.T) {
}
func TestMakeBlockUpgrades(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var b Block
b.BlockHeader.GenesisID = t.Name()
b.CurrentProtocol = proto1
@@ -195,6 +202,8 @@ func TestMakeBlockUpgrades(t *testing.T) {
}
func TestBlockUnsupported(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var b Block
b.CurrentProtocol = protoUnsupported
@@ -208,6 +217,8 @@ func TestBlockUnsupported(t *testing.T) {
}
func TestTime(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var prev Block
prev.BlockHeader.GenesisID = t.Name()
prev.CurrentProtocol = proto1
@@ -235,6 +246,8 @@ func TestTime(t *testing.T) {
}
func TestRewardsLevel(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
var prev Block
prev.RewardsLevel = 1
@@ -247,6 +260,8 @@ func TestRewardsLevel(t *testing.T) {
}
func TestRewardsLevelWithResidue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
var prev Block
@@ -261,6 +276,8 @@ func TestRewardsLevelWithResidue(t *testing.T) {
}
func TestRewardsLevelNoUnits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
var prev Block
@@ -274,6 +291,8 @@ func TestRewardsLevelNoUnits(t *testing.T) {
}
func TestTinyLevel(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
var prev Block
@@ -286,6 +305,8 @@ func TestTinyLevel(t *testing.T) {
}
func TestRewardsRate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var prev Block
prev.RewardsLevel = 1
prev.RewardsRate = 10
@@ -303,6 +324,8 @@ func TestRewardsRate(t *testing.T) {
}
func TestRewardsRateRefresh(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var prev Block
prev.RewardsLevel = 1
prev.RewardsRate = 10
@@ -320,6 +343,8 @@ func TestRewardsRateRefresh(t *testing.T) {
}
func TestEncodeDecodeSignedTxn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var b Block
b.BlockHeader.GenesisID = "foo"
crypto.RandBytes(b.BlockHeader.GenesisHash[:])
@@ -337,6 +362,8 @@ func TestEncodeDecodeSignedTxn(t *testing.T) {
}
func TestEncodeMalformedSignedTxn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var b Block
b.BlockHeader.GenesisID = "foo"
b.BlockHeader.CurrentProtocol = protocol.ConsensusCurrentVersion
@@ -360,6 +387,8 @@ func TestEncodeMalformedSignedTxn(t *testing.T) {
}
func TestDecodeMalformedSignedTxn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var b Block
b.BlockHeader.GenesisID = "foo"
b.BlockHeader.CurrentProtocol = protocol.ConsensusCurrentVersion
@@ -379,6 +408,8 @@ func TestDecodeMalformedSignedTxn(t *testing.T) {
// TestInitialRewardsRateCalculation perform positive and negative testing for the InitialRewardsRateCalculation fix by
// running the rounds in the same way eval() is executing them over RewardsRateRefreshInterval rounds.
func TestInitialRewardsRateCalculation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
consensusParams := config.Consensus[protocol.ConsensusCurrentVersion]
runTest := func() bool {
diff --git a/data/bookkeeping/encoding_test.go b/data/bookkeeping/encoding_test.go
index bab98b227..0c82710f7 100644
--- a/data/bookkeeping/encoding_test.go
+++ b/data/bookkeeping/encoding_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestEmptyEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var b Block
require.Equal(t, 1, len(protocol.Encode(&b)))
@@ -35,6 +38,8 @@ func TestEmptyEncoding(t *testing.T) {
}
func TestBlockWithTxnEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
txn := transactions.Transaction{
Type: protocol.PaymentTx,
PaymentTxnFields: transactions.PaymentTxnFields{
diff --git a/data/bookkeeping/msgp_gen_test.go b/data/bookkeeping/msgp_gen_test.go
index d0c33bd82..44ff62e2d 100644
--- a/data/bookkeeping/msgp_gen_test.go
+++ b/data/bookkeeping/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Block{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalBlock(b *testing.B) {
}
func TestMarshalUnmarshalBlockHeader(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := BlockHeader{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalBlockHeader(b *testing.B) {
}
func TestMarshalUnmarshalCompactCertState(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := CompactCertState{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalCompactCertState(b *testing.B) {
}
func TestMarshalUnmarshalGenesis(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Genesis{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -248,6 +253,7 @@ func BenchmarkUnmarshalGenesis(b *testing.B) {
}
func TestMarshalUnmarshalGenesisAllocation(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := GenesisAllocation{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -307,6 +313,7 @@ func BenchmarkUnmarshalGenesisAllocation(b *testing.B) {
}
func TestMarshalUnmarshalRewardsState(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := RewardsState{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -366,6 +373,7 @@ func BenchmarkUnmarshalRewardsState(b *testing.B) {
}
func TestMarshalUnmarshalUpgradeVote(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := UpgradeVote{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/data/bookkeeping/txn_merkle_test.go b/data/bookkeeping/txn_merkle_test.go
index 6af499b3e..5f7d6b2db 100644
--- a/data/bookkeeping/txn_merkle_test.go
+++ b/data/bookkeeping/txn_merkle_test.go
@@ -27,15 +27,20 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestTxnMerkleElemHash(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var tme txnMerkleElem
crypto.RandBytes(tme.stib.SignedTxn.Txn.Header.Sender[:])
require.Equal(t, crypto.HashObj(&tme), tme.Hash())
}
func TestTxnMerkle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for ntxn := uint64(0); ntxn < 128; ntxn++ {
var b Block
b.CurrentProtocol = protocol.ConsensusCurrentVersion
diff --git a/data/committee/credential_test.go b/data/committee/credential_test.go
index c8d56716d..2132a8d1f 100644
--- a/data/committee/credential_test.go
+++ b/data/committee/credential_test.go
@@ -23,11 +23,14 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// test SelfCheckSelected (should always be true, with current testingenv parameters)
// and then set balance to 0 and test not SelfCheckSelected
func TestAccountSelected(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
N := 1
for i := 0; i < N; i++ {
selParams, _, round, addresses, _, vrfSecrets, _, _ := testingenv(t, 100, 2000)
@@ -86,6 +89,8 @@ func TestAccountSelected(t *testing.T) {
}
func TestRichAccountSelected(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
selParams, _, round, addresses, _, vrfSecrets, _, _ := testingenv(t, 10, 2000)
period := Period(0)
@@ -137,6 +142,8 @@ func TestRichAccountSelected(t *testing.T) {
}
func TestPoorAccountSelectedLeaders(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
N := 2
failsLeaders := 0
leaders := make([]uint64, N)
@@ -180,6 +187,8 @@ func TestPoorAccountSelectedLeaders(t *testing.T) {
}
func TestPoorAccountSelectedCommittee(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
N := 1
committee := uint64(0)
for i := 0; i < N; i++ {
@@ -218,6 +227,8 @@ func TestPoorAccountSelectedCommittee(t *testing.T) {
}
func TestNoMoneyAccountNotSelected(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
N := 1
for i := 0; i < N; i++ {
selParams, _, round, addresses, _, _, _, _ := testingenv(t, 10, 2000)
@@ -249,6 +260,8 @@ func TestNoMoneyAccountNotSelected(t *testing.T) {
}
func TestLeadersSelected(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
selParams, _, round, addresses, _, vrfSecrets, _, _ := testingenv(t, 100, 2000)
period := Period(0)
@@ -279,6 +292,8 @@ func TestLeadersSelected(t *testing.T) {
}
func TestCommitteeSelected(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
selParams, _, round, addresses, _, vrfSecrets, _, _ := testingenv(t, 100, 2000)
period := Period(0)
@@ -309,6 +324,8 @@ func TestCommitteeSelected(t *testing.T) {
}
func TestAccountNotSelected(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
selParams, _, round, addresses, _, vrfSecrets, _, _ := testingenv(t, 100, 2000)
period := Period(0)
leaders := uint64(0)
diff --git a/data/committee/encoding_test.go b/data/committee/encoding_test.go
index 528da39c5..f9491dbbf 100644
--- a/data/committee/encoding_test.go
+++ b/data/committee/encoding_test.go
@@ -22,9 +22,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestEmptyEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var c Credential
require.Equal(t, 1, len(protocol.Encode(&c)))
}
diff --git a/data/committee/msgp_gen_test.go b/data/committee/msgp_gen_test.go
index 5c4b03ec8..7a8946a6c 100644
--- a/data/committee/msgp_gen_test.go
+++ b/data/committee/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalCredential(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Credential{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalCredential(b *testing.B) {
}
func TestMarshalUnmarshalSeed(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Seed{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalSeed(b *testing.B) {
}
func TestMarshalUnmarshalUnauthenticatedCredential(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := UnauthenticatedCredential{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalUnauthenticatedCredential(b *testing.B) {
}
func TestMarshalUnmarshalhashableCredential(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := hashableCredential{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/data/hashable/msgp_gen_test.go b/data/hashable/msgp_gen_test.go
index 92efd0110..131eaebe0 100644
--- a/data/hashable/msgp_gen_test.go
+++ b/data/hashable/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalMessage(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Message{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/data/ledger_test.go b/data/ledger_test.go
index a9b42cbbd..e2a231802 100644
--- a/data/ledger_test.go
+++ b/data/ledger_test.go
@@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var testPoolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
@@ -112,6 +113,8 @@ func testGenerateInitState(tb testing.TB, proto protocol.ConsensusVersion) (gene
}
func TestLedgerCirculation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
genesisInitState, keys := testGenerateInitState(t, protocol.ConsensusCurrentVersion)
const inMem = true
@@ -243,6 +246,8 @@ func TestLedgerCirculation(t *testing.T) {
}
func TestLedgerSeed(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
genesisInitState, _ := testGenerateInitState(t, protocol.ConsensusCurrentVersion)
const inMem = true
@@ -315,6 +320,8 @@ func TestLedgerSeed(t *testing.T) {
}
func TestConsensusVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// find a consensus protocol that leads to ConsensusCurrentVersion
var previousProtocol protocol.ConsensusVersion
for ver, params := range config.Consensus {
diff --git a/data/pools/transactionPool_test.go b/data/pools/transactionPool_test.go
index 3aaabb6ae..59d81e888 100644
--- a/data/pools/transactionPool_test.go
+++ b/data/pools/transactionPool_test.go
@@ -35,6 +35,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var proto = config.Consensus[protocol.ConsensusCurrentVersion]
@@ -135,6 +136,8 @@ func initAccFixed(initAddrs []basics.Address, bal uint64) map[basics.Address]bas
const testPoolSize = 1000
func TestMinBalanceOK(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -176,6 +179,8 @@ func TestMinBalanceOK(t *testing.T) {
}
func TestSenderGoesBelowMinBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -217,6 +222,8 @@ func TestSenderGoesBelowMinBalance(t *testing.T) {
}
func TestSenderGoesBelowMinBalanceDueToAssets(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -287,6 +294,8 @@ func TestSenderGoesBelowMinBalanceDueToAssets(t *testing.T) {
}
func TestCloseAccount(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -348,6 +357,8 @@ func TestCloseAccount(t *testing.T) {
}
func TestCloseAccountWhileTxIsPending(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -409,6 +420,8 @@ func TestCloseAccountWhileTxIsPending(t *testing.T) {
}
func TestClosingAccountBelowMinBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -452,6 +465,8 @@ func TestClosingAccountBelowMinBalance(t *testing.T) {
}
func TestRecipientGoesBelowMinBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -493,6 +508,8 @@ func TestRecipientGoesBelowMinBalance(t *testing.T) {
}
func TestRememberForget(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -558,6 +575,8 @@ func TestRememberForget(t *testing.T) {
// Test that clean up works
func TestCleanUp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 10
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -635,6 +654,8 @@ func TestCleanUp(t *testing.T) {
}
func TestFixOverflowOnNewBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 10
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -729,6 +750,8 @@ func TestFixOverflowOnNewBlock(t *testing.T) {
}
func TestOverspender(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 2
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -790,6 +813,8 @@ func TestOverspender(t *testing.T) {
}
func TestRemove(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 2
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -831,6 +856,8 @@ func TestRemove(t *testing.T) {
}
func TestLogicSigOK(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
oparams := config.Consensus[protocol.ConsensusCurrentVersion]
params := oparams
params.LogicSigMaxCost = 20000
@@ -889,6 +916,8 @@ func TestLogicSigOK(t *testing.T) {
}
func TestTransactionPool_CurrentFeePerByte(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 5
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
@@ -1158,6 +1187,8 @@ func BenchmarkTransactionPoolSteadyState(b *testing.B) {
}
func TestTxPoolSizeLimits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numOfAccounts := 2
// Generate accounts
secrets := make([]*crypto.SignatureSecrets, numOfAccounts)
diff --git a/data/transactions/application_test.go b/data/transactions/application_test.go
index 9c47a437a..78670bf18 100644
--- a/data/transactions/application_test.go
+++ b/data/transactions/application_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestApplicationCallFieldsNotChanged(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
af := ApplicationCallTxnFields{}
s := reflect.ValueOf(&af).Elem()
@@ -38,6 +41,8 @@ func TestApplicationCallFieldsNotChanged(t *testing.T) {
}
func TestApplicationCallFieldsEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ac := ApplicationCallTxnFields{}
@@ -93,6 +98,8 @@ func TestApplicationCallFieldsEmpty(t *testing.T) {
}
func TestEncodedAppTxnAllocationBounds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// ensure that all the supported protocols have value limits less or
// equal to their corresponding codec allocbounds
for protoVer, proto := range config.Consensus {
diff --git a/data/transactions/logic/README.md b/data/transactions/logic/README.md
index 02ca1cfdc..f6a219f1c 100644
--- a/data/transactions/logic/README.md
+++ b/data/transactions/logic/README.md
@@ -360,6 +360,8 @@ App fields used in the `app_params_get` opcode.
| `dup` | duplicate last value on stack |
| `dup2` | duplicate two last values on stack: A, B -> A, B, A, B |
| `dig n` | push the Nth value from the top of the stack. dig 0 is equivalent to dup |
+| `cover n` | remove top of stack, and place it down the stack such that N elements are above it |
+| `uncover n` | remove the value at depth N in the stack and shift above items down so the Nth deep value is on top of the stack |
| `swap` | swaps two last values on stack: A, B -> B, A |
| `select` | selects one of two values based on top-of-stack: A, B, C -> (if C != 0 then B else A) |
| `assert` | immediately fail unless value X is a non-zero number |
diff --git a/data/transactions/logic/TEAL_opcodes.md b/data/transactions/logic/TEAL_opcodes.md
index 0aa9c4e8f..b262a8042 100644
--- a/data/transactions/logic/TEAL_opcodes.md
+++ b/data/transactions/logic/TEAL_opcodes.md
@@ -660,6 +660,22 @@ See `bnz` for details on how branches work. `b` always jumps to the offset.
- selects one of two values based on top-of-stack: A, B, C -> (if C != 0 then B else A)
- LogicSigVersion >= 3
+## cover n
+
+- Opcode: 0x4e {uint8 depth}
+- Pops: *... stack*, any
+- Pushes: any
+- remove top of stack, and place it down the stack such that N elements are above it
+- LogicSigVersion >= 5
+
+## uncover n
+
+- Opcode: 0x4f {uint8 depth}
+- Pops: *... stack*, any
+- Pushes: any
+- remove the value at depth N in the stack and shift above items down so the Nth deep value is on top of the stack
+- LogicSigVersion >= 5
+
## concat
- Opcode: 0x50
diff --git a/data/transactions/logic/assembler.go b/data/transactions/logic/assembler.go
index 231867d29..694c156c0 100644
--- a/data/transactions/logic/assembler.go
+++ b/data/transactions/logic/assembler.go
@@ -1101,6 +1101,62 @@ func typeDig(ops *OpStream, args []string) (StackTypes, StackTypes) {
return anys, returns
}
+func typeCover(ops *OpStream, args []string) (StackTypes, StackTypes) {
+ if len(args) == 0 {
+ return oneAny, oneAny
+ }
+ n, err := strconv.ParseUint(args[0], 0, 64)
+ if err != nil {
+ return oneAny, oneAny
+ }
+ depth := int(n) + 1
+ anys := make(StackTypes, depth)
+ for i := range anys {
+ anys[i] = StackAny
+ }
+ returns := make(StackTypes, depth)
+ for i := range returns {
+ returns[i] = StackAny
+ }
+ idx := len(ops.typeStack) - depth
+ if idx >= 0 {
+ sv := ops.typeStack[len(ops.typeStack)-1]
+ for i := idx; i < len(ops.typeStack)-1; i++ {
+ returns[i-idx+1] = ops.typeStack[i]
+ }
+ returns[len(returns)-depth] = sv
+ }
+ return anys, returns
+}
+
+func typeUncover(ops *OpStream, args []string) (StackTypes, StackTypes) {
+ if len(args) == 0 {
+ return oneAny, oneAny
+ }
+ n, err := strconv.ParseUint(args[0], 0, 64)
+ if err != nil {
+ return oneAny, oneAny
+ }
+ depth := int(n) + 1
+ anys := make(StackTypes, depth)
+ for i := range anys {
+ anys[i] = StackAny
+ }
+ returns := make(StackTypes, depth)
+ for i := range returns {
+ returns[i] = StackAny
+ }
+ idx := len(ops.typeStack) - depth
+ if idx >= 0 {
+ sv := ops.typeStack[idx]
+ for i := idx + 1; i < len(ops.typeStack); i++ {
+ returns[i-idx-1] = ops.typeStack[i]
+ }
+ returns[len(returns)-1] = sv
+ }
+ return anys, returns
+}
+
// keywords handle parsing and assembling special asm language constructs like 'addr'
// We use OpSpec here, but somewhat degenerate, since they don't have opcodes or eval functions
var keywords = map[string]OpSpec{
diff --git a/data/transactions/logic/assembler_test.go b/data/transactions/logic/assembler_test.go
index 3dbeaf20c..c7d18c150 100644
--- a/data/transactions/logic/assembler_test.go
+++ b/data/transactions/logic/assembler_test.go
@@ -24,6 +24,8 @@ import (
"testing"
"github.com/stretchr/testify/require"
+
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// used by TestAssemble and others, see UPDATE PROCEDURE in TestAssemble()
@@ -294,6 +296,8 @@ int 100
const v5Nonsense = `
app_params_get AppExtraProgramPages
+cover 1
+uncover 1
byte 0x0123456789abcd
extract 0 8
int 0
@@ -320,7 +324,7 @@ var compiled = map[uint64]string{
2: "022008b7a60cf8acd19181cf959a12f8acd19181cf951af8acd19181cf15f8acd191810f01020026050212340c68656c6c6f20776f726c6421208dae2087fbba51304eb02b91f656948397a7946390e8cb70fc9ea4d95f92251d024242047465737400320032013202320328292929292a0431003101310231043105310731083109310a310b310c310d310e310f3111311231133114311533000033000133000233000433000533000733000833000933000a33000b33000c33000d33000e33000f3300113300123300133300143300152d2e0102222324252104082209240a220b230c240d250e230f23102311231223132314181b1c2b171615400003290349483403350222231d4a484848482a50512a63222352410003420000432105602105612105270463484821052b62482b642b65484821052b2106662b21056721072b682b692107210570004848210771004848361c0037001a0031183119311b311d311e311f3120210721051e312131223123312431253126312731283129312a312b312c312d312e312f",
3: "032008b7a60cf8acd19181cf959a12f8acd19181cf951af8acd19181cf15f8acd191810f01020026050212340c68656c6c6f20776f726c6421208dae2087fbba51304eb02b91f656948397a7946390e8cb70fc9ea4d95f92251d024242047465737400320032013202320328292929292a0431003101310231043105310731083109310a310b310c310d310e310f3111311231133114311533000033000133000233000433000533000733000833000933000a33000b33000c33000d33000e33000f3300113300123300133300143300152d2e0102222324252104082209240a220b230c240d250e230f23102311231223132314181b1c2b171615400003290349483403350222231d4a484848482a50512a63222352410003420000432105602105612105270463484821052b62482b642b65484821052b2106662b21056721072b682b692107210570004848210771004848361c0037001a0031183119311b311d311e311f3120210721051e312131223123312431253126312731283129312a312b312c312d312e312f4478222105531421055427042106552105082106564c4d4b02210538212106391c0081e80780046a6f686e",
4: "042004010200b7a60c26040242420c68656c6c6f20776f726c6421208dae2087fbba51304eb02b91f656948397a7946390e8cb70fc9ea4d95f92251d047465737400320032013202320380021234292929292a0431003101310231043105310731083109310a310b310c310d310e310f3111311231133114311533000033000133000233000433000533000733000833000933000a33000b33000c33000d33000e33000f3300113300123300133300143300152d2e01022581f8acd19181cf959a1281f8acd19181cf951a81f8acd19181cf1581f8acd191810f082209240a220b230c240d250e230f23102311231223132314181b1c28171615400003290349483403350222231d4a484848482a50512a632223524100034200004322602261222b634848222862482864286548482228236628226724286828692422700048482471004848361c0037001a0031183119311b311d311e311f312024221e312131223123312431253126312731283129312a312b312c312d312e312f44782522531422542b2355220823564c4d4b0222382123391c0081e80780046a6f686e2281d00f24231f880003420001892223902291922394239593a0a1a2a3a4a5a6a7a8a9aaabacadae23af3a00003b003c003d8164",
- 5: "052004010200b7a60c26040242420c68656c6c6f20776f726c6421208dae2087fbba51304eb02b91f656948397a7946390e8cb70fc9ea4d95f92251d047465737400320032013202320380021234292929292a0431003101310231043105310731083109310a310b310c310d310e310f3111311231133114311533000033000133000233000433000533000733000833000933000a33000b33000c33000d33000e33000f3300113300123300133300143300152d2e01022581f8acd19181cf959a1281f8acd19181cf951a81f8acd19181cf1581f8acd191810f082209240a220b230c240d250e230f23102311231223132314181b1c28171615400003290349483403350222231d4a484848482a50512a632223524100034200004322602261222b634848222862482864286548482228236628226724286828692422700048482471004848361c0037001a0031183119311b311d311e311f312024221e312131223123312431253126312731283129312a312b312c312d312e312f44782522531422542b2355220823564c4d4b0222382123391c0081e80780046a6f686e2281d00f24231f880003420001892223902291922394239593a0a1a2a3a4a5a6a7a8a9aaabacadae23af3a00003b003c003d8164720680070123456789abcd57000824810858245b245a2459",
+ 5: "052004010200b7a60c26040242420c68656c6c6f20776f726c6421208dae2087fbba51304eb02b91f656948397a7946390e8cb70fc9ea4d95f92251d047465737400320032013202320380021234292929292a0431003101310231043105310731083109310a310b310c310d310e310f3111311231133114311533000033000133000233000433000533000733000833000933000a33000b33000c33000d33000e33000f3300113300123300133300143300152d2e01022581f8acd19181cf959a1281f8acd19181cf951a81f8acd19181cf1581f8acd191810f082209240a220b230c240d250e230f23102311231223132314181b1c28171615400003290349483403350222231d4a484848482a50512a632223524100034200004322602261222b634848222862482864286548482228236628226724286828692422700048482471004848361c0037001a0031183119311b311d311e311f312024221e312131223123312431253126312731283129312a312b312c312d312e312f44782522531422542b2355220823564c4d4b0222382123391c0081e80780046a6f686e2281d00f24231f880003420001892223902291922394239593a0a1a2a3a4a5a6a7a8a9aaabacadae23af3a00003b003c003d816472064e014f0180070123456789abcd57000824810858245b245a2459",
}
func pseudoOp(opcode string) bool {
@@ -334,6 +338,8 @@ func pseudoOp(opcode string) bool {
// Check that assembly output is stable across time.
func TestAssemble(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// UPDATE PROCEDURE:
// Run test. It should pass. If test is not passing, do not change this test, fix the assembler first.
// Extend this test program text. Append instructions to the end so that the program byte hex is visually similar and also simply extended by some new bytes,
@@ -372,6 +378,8 @@ func TestAssemble(t *testing.T) {
}
func TestAssembleAlias(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source1 := `txn Accounts 0 // alias to txna
pop
@@ -466,6 +474,8 @@ func testLine(t *testing.T, line string, ver uint64, expected string) {
testProg(t, source, ver, expect{2, expected})
}
func TestAssembleTxna(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLine(t, "txna Accounts 256", AssemblerMaxVersion, "txna array index beyond 255: 256")
testLine(t, "txna ApplicationArgs 256", AssemblerMaxVersion, "txna array index beyond 255: 256")
testLine(t, "txna Sender 256", AssemblerMaxVersion, "txna unknown field: \"Sender\"")
@@ -494,11 +504,15 @@ func TestAssembleTxna(t *testing.T) {
}
func TestAssembleGlobal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLine(t, "global", AssemblerMaxVersion, "global expects one argument")
testLine(t, "global a", AssemblerMaxVersion, "global unknown field: \"a\"")
}
func TestAssembleDefault(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
source := `byte 0x1122334455
int 1
+
@@ -513,6 +527,8 @@ func mutateProgVersion(version uint64, prog string) string {
}
func TestOpUint(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
ops := OpStream{Version: v}
@@ -527,6 +543,8 @@ func TestOpUint(t *testing.T) {
}
func TestOpUint64(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -542,6 +560,8 @@ func TestOpUint64(t *testing.T) {
}
func TestOpBytes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -556,6 +576,8 @@ func TestOpBytes(t *testing.T) {
}
func TestAssembleInt(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
expectedDefaultConsts := "012001bef5fad70c22"
@@ -588,6 +610,8 @@ base64.b16encode(raw.encode())
*/
func TestAssembleBytes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
variations := []string{
"byte b32 MFRGGZDFMY",
@@ -629,6 +653,8 @@ func TestAssembleBytes(t *testing.T) {
}
func TestAssembleBytesString(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
testLine(t, `byte "foo bar"`, v, "")
@@ -638,6 +664,8 @@ func TestAssembleBytesString(t *testing.T) {
}
func TestAssembleOptimizedConstants(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
t.Run("Bytes", func(t *testing.T) {
@@ -845,6 +873,8 @@ bytec_1 // 0x0103
}
func TestAssembleOptimizedUint(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
program := `
@@ -868,6 +898,8 @@ int ClearState
}
func TestFieldsFromLine(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
line := "op arg"
fields := fieldsFromLine(line)
require.Equal(t, 2, len(fields))
@@ -1074,6 +1106,8 @@ func TestFieldsFromLine(t *testing.T) {
}
func TestAssembleRejectNegJump(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `wat:
int 1
@@ -1092,6 +1126,8 @@ int 2`
}
func TestAssembleBase64(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `byte base64 //GWRM+yy3BCavBDXO/FYTNZ6o2Jai5edsMCBdDEz+0=
byte base64 avGWRM+yy3BCavBDXO/FYTNZ6o2Jai5edsMCBdDEz//=
@@ -1125,6 +1161,8 @@ byte b64 avGWRM+yy3BCavBDXO/FYTNZ6o2Jai5edsMCBdDEz//=
}
func TestAssembleRejectUnkLabel(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `int 1
bnz nowhere
@@ -1137,6 +1175,8 @@ int 2`
}
func TestAssembleJumpToTheEnd(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `intcblock 1
intc 0
@@ -1152,6 +1192,8 @@ done:`
}
func TestMultipleErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `int 1
bnz nowhere
@@ -1168,6 +1210,8 @@ int 2`
}
func TestAssembleDisassemble(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Specifically constructed program text that should be recreated by Disassemble()
t.Parallel()
text := fmt.Sprintf(`#pragma version %d
@@ -1282,6 +1326,8 @@ txn ExtraProgramPages
}
func TestAssembleDisassembleCycle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Test that disassembly re-assembles to the same program bytes.
// Disassembly won't necessarily perfectly recreate the source text, but assembling the result of Disassemble() should be the same program bytes.
t.Parallel()
@@ -1315,6 +1361,8 @@ func TestAssembleDisassembleCycle(t *testing.T) {
}
func TestConstantDisassembly(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
ops := testProg(t, "int 47", AssemblerMaxVersion)
@@ -1361,6 +1409,8 @@ func TestConstantArgs(t *testing.T) {
}
func TestAssembleDisassembleErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `txn Sender`
@@ -1472,6 +1522,8 @@ func TestAssembleDisassembleErrors(t *testing.T) {
}
func TestAssembleVersions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testLine(t, "txna Accounts 0", AssemblerMaxVersion, "")
testLine(t, "txna Accounts 0", 2, "")
@@ -1479,6 +1531,8 @@ func TestAssembleVersions(t *testing.T) {
}
func TestAssembleBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `byte 0x00
@@ -1494,6 +1548,8 @@ int 1
}
func TestAssembleMinBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `byte 0x00
@@ -1509,6 +1565,8 @@ int 1
}
func TestAssembleAsset(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
introduction := OpsByName[LogicVersion]["asset_holding_get"].Version
for v := introduction; v <= AssemblerMaxVersion; v++ {
@@ -1530,6 +1588,8 @@ func TestAssembleAsset(t *testing.T) {
}
func TestDisassembleSingleOp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
@@ -1545,6 +1605,8 @@ func TestDisassembleSingleOp(t *testing.T) {
}
func TestDisassembleInt(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
txnSample := fmt.Sprintf("#pragma version %d\nint 17\nint 27\nint 37\nint 47\nint 5\nint 17\n", AssemblerMaxVersion)
ops := testProg(t, txnSample, AssemblerMaxVersion)
@@ -1561,6 +1623,8 @@ func TestDisassembleInt(t *testing.T) {
}
func TestDisassembleTxna(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// txn was 1, but this tests both
introduction := OpsByName[LogicVersion]["gtxna"].Version
@@ -1588,6 +1652,8 @@ func TestDisassembleTxna(t *testing.T) {
}
func TestDisassembleGtxna(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// check gtxn and gtxna are properly disassembled
@@ -1615,6 +1681,8 @@ func TestDisassembleGtxna(t *testing.T) {
}
func TestDisassemblePushConst(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// check pushint and pushbytes are properly disassembled
intSample := fmt.Sprintf("#pragma version %d\npushint 1\n", AssemblerMaxVersion)
@@ -1643,6 +1711,8 @@ func TestDisassemblePushConst(t *testing.T) {
}
func TestDisassembleLastLabel(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// starting from TEAL v2 branching to the last line are legal
@@ -1664,6 +1734,8 @@ label1:
}
func TestAssembleOffsets(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := "err"
ops := testProg(t, source, AssemblerMaxVersion)
@@ -1762,6 +1834,8 @@ err
}
func TestHasStatefulOps(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := "int 1"
ops, err := AssembleStringWithVersion(source, AssemblerMaxVersion)
@@ -1783,6 +1857,8 @@ err
}
func TestStringLiteralParsing(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
s := `"test"`
e := []byte(`test`)
@@ -1878,6 +1954,8 @@ func TestStringLiteralParsing(t *testing.T) {
}
func TestPragmas(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
text := fmt.Sprintf("#pragma version %d", v)
@@ -1941,6 +2019,8 @@ func TestPragmas(t *testing.T) {
}
func TestAssemblePragmaVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `#pragma version 1
int 1
@@ -1993,6 +2073,8 @@ len
}
func TestAssembleConstants(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2006,6 +2088,8 @@ func TestAssembleConstants(t *testing.T) {
}
func TestErrShortBytecblock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
text := `intcblock 0x1234567812345678 0x1234567812345671 0x1234567812345672 0x1234567812345673 4 5 6 7 8`
ops, err := AssembleStringWithVersion(text, 1)
require.NoError(t, err)
@@ -2019,6 +2103,8 @@ func TestErrShortBytecblock(t *testing.T) {
}
func TestBranchAssemblyTypeCheck(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
text := `
int 0 // current app id [0]
int 1 // key [1, 0]
@@ -2078,3 +2164,19 @@ func TestDigAsm(t *testing.T) {
expect{6, "+ arg 1..."})
}
+
+func TestCoverAsm(t *testing.T) {
+ t.Parallel()
+ testProg(t, `int 4; byte "john"; int 5; cover 2; pop; +`, AssemblerMaxVersion)
+ testProg(t, `int 4; byte "ayush"; int 5; cover 1; pop; +`, AssemblerMaxVersion)
+ testProg(t, `int 4; byte "john"; int 5; cover 2; +`, AssemblerMaxVersion, expect{5, "+ arg 1..."})
+
+}
+
+func TestUncoverAsm(t *testing.T) {
+ t.Parallel()
+ testProg(t, `int 4; byte "john"; int 5; uncover 2; +`, AssemblerMaxVersion)
+ testProg(t, `int 4; byte "ayush"; int 5; uncover 1; pop; +`, AssemblerMaxVersion)
+ testProg(t, `int 1; byte "jj"; byte "ayush"; byte "john"; int 5; uncover 4; +`, AssemblerMaxVersion)
+ testProg(t, `int 4; byte "ayush"; int 5; uncover 1; +`, AssemblerMaxVersion, expect{5, "+ arg 1..."})
+}
diff --git a/data/transactions/logic/backwardCompat_test.go b/data/transactions/logic/backwardCompat_test.go
index 5c6ada563..68dcf73bc 100644
--- a/data/transactions/logic/backwardCompat_test.go
+++ b/data/transactions/logic/backwardCompat_test.go
@@ -26,6 +26,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -250,6 +251,8 @@ dup
var programTEALv1 = "01200500010220ffffffffffffffffff012608014120559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd0142201f675bff07515f5df96737194ea945c36c41e7b4fcef307b7cd4d0e602a6911101432034b99f8dde1ba273c0a28cf5b2e4dbe497f8cb2453de0c8ba6d578c9431a62cb0100200000000000000000000000000000000000000000000000000000000000000000280129122a022b1210270403270512102d2e2f041022082209230a230b240c220d230e230f231022112312231314301525121617182319231a221b21041c1d12222312242512102104231210482829122a2b121027042706121048310031071331013102121022310413103105310613103108311613103109310a1210310b310f1310310c310d1210310e31101310311131121310311331141210311531171210483300003300071333000133000212102233000413103300053300061310330008330016131033000933000a121033000b33000f131033000c33000d121033000e3300101310330011330012131033001333001412103300153300171210483200320112320232041310320327071210350034001040000100234912"
func TestBackwardCompatTEALv1(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var s crypto.Seed
crypto.RandBytes(s[:])
@@ -373,6 +376,8 @@ func TestBackwardCompatTEALv1(t *testing.T) {
// ensure v2 fields error on pre TEAL v2 logicsig version
// ensure v2 fields error in v1 program
func TestBackwardCompatGlobalFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fields []globalFieldSpec
for _, fs := range globalFieldSpecs {
@@ -429,6 +434,8 @@ func TestBackwardCompatGlobalFields(t *testing.T) {
// ensure v2 fields error in v1 program
func TestBackwardCompatTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fields []txnFieldSpec
for _, fs := range txnFieldSpecs {
@@ -512,6 +519,8 @@ func TestBackwardCompatTxnFields(t *testing.T) {
}
func TestBackwardCompatAssemble(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// TEAL v1 does not allow branching to the last line
// TEAL v2 makes such programs legal
t.Parallel()
diff --git a/data/transactions/logic/debugger_test.go b/data/transactions/logic/debugger_test.go
index 54d479b4d..a9c0603dc 100644
--- a/data/transactions/logic/debugger_test.go
+++ b/data/transactions/logic/debugger_test.go
@@ -22,6 +22,7 @@ import (
"testing"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -63,6 +64,8 @@ bytec 4
`
func TestWebDebuggerManual(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
debugURL := os.Getenv("TEAL_DEBUGGER_URL")
if len(debugURL) == 0 {
return
@@ -114,6 +117,8 @@ func (d *testDbgHook) Complete(state *DebugState) error {
}
func TestDebuggerHook(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testDbg := testDbgHook{}
ops, err := AssembleString(testProgram)
require.NoError(t, err)
@@ -129,6 +134,8 @@ func TestDebuggerHook(t *testing.T) {
}
func TestLineToPC(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dState := DebugState{
Disassembly: "abc\ndef\nghi",
PCOffset: []PCOffset{{PC: 1, Offset: 4}, {PC: 2, Offset: 8}, {PC: 3, Offset: 12}},
@@ -164,6 +171,8 @@ func TestLineToPC(t *testing.T) {
}
func TestValueDeltaToValueDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
vDelta := basics.ValueDelta{
Action: basics.SetUintAction,
Bytes: "some string",
diff --git a/data/transactions/logic/doc.go b/data/transactions/logic/doc.go
index c474ced80..e8e784eb3 100644
--- a/data/transactions/logic/doc.go
+++ b/data/transactions/logic/doc.go
@@ -100,6 +100,8 @@ var opDocByName = map[string]string{
"dup": "duplicate last value on stack",
"dup2": "duplicate two last values on stack: A, B -> A, B, A, B",
"dig": "push the Nth value from the top of the stack. dig 0 is equivalent to dup",
+ "cover": "remove top of stack, and place it down the stack such that N elements are above it",
+ "uncover": "remove the value at depth N in the stack and shift above items down so the Nth deep value is on top of the stack",
"swap": "swaps two last values on stack: A, B -> B, A",
"select": "selects one of two values based on top-of-stack: A, B, C -> (if C != 0 then B else A)",
"concat": "pop two byte-arrays A and B and join them, push the result",
@@ -182,6 +184,8 @@ var opcodeImmediateNotes = map[string]string{
"substring": "{uint8 start position} {uint8 end position}",
"extract": "{uint8 start position} {uint8 length}",
"dig": "{uint8 depth}",
+ "cover": "{uint8 depth}",
+ "uncover": "{uint8 depth}",
"asset_holding_get": "{uint8 asset holding field index}",
"asset_params_get": "{uint8 asset params field index}",
"app_params_get": "{uint8 app params field index}",
@@ -246,7 +250,7 @@ var OpGroups = map[string][]string{
"Byteslice Arithmetic": {"b+", "b-", "b/", "b*", "b<", "b>", "b<=", "b>=", "b==", "b!=", "b%"},
"Byteslice Logic": {"b|", "b&", "b^", "b~"},
"Loading Values": {"intcblock", "intc", "intc_0", "intc_1", "intc_2", "intc_3", "pushint", "bytecblock", "bytec", "bytec_0", "bytec_1", "bytec_2", "bytec_3", "pushbytes", "bzero", "arg", "arg_0", "arg_1", "arg_2", "arg_3", "txn", "gtxn", "txna", "gtxna", "gtxns", "gtxnsa", "global", "load", "store", "gload", "gloads", "gaid", "gaids"},
- "Flow Control": {"err", "bnz", "bz", "b", "return", "pop", "dup", "dup2", "dig", "swap", "select", "assert", "callsub", "retsub"},
+ "Flow Control": {"err", "bnz", "bz", "b", "return", "pop", "dup", "dup2", "dig", "cover", "uncover", "swap", "select", "assert", "callsub", "retsub"},
"State Access": {"balance", "min_balance", "app_opted_in", "app_local_get", "app_local_get_ex", "app_global_get", "app_global_get_ex", "app_local_put", "app_global_put", "app_local_del", "app_global_del", "asset_holding_get", "asset_params_get", "app_params_get"},
}
diff --git a/data/transactions/logic/doc_test.go b/data/transactions/logic/doc_test.go
index 625783993..ad87f4a01 100644
--- a/data/transactions/logic/doc_test.go
+++ b/data/transactions/logic/doc_test.go
@@ -20,10 +20,13 @@ import (
"strings"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestOpDocs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
opsSeen := make(map[string]bool, len(OpSpecs))
for _, op := range OpSpecs {
opsSeen[op.Name] = false
@@ -51,6 +54,8 @@ func TestOpDocs(t *testing.T) {
}
func TestOpGroupCoverage(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
opsSeen := make(map[string]bool, len(OpSpecs))
for _, op := range OpSpecs {
opsSeen[op.Name] = false
@@ -73,6 +78,8 @@ func TestOpGroupCoverage(t *testing.T) {
}
func TestOpDoc(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
xd := OpDoc("txn")
require.NotEmpty(t, xd)
xd = OpDoc("NOT AN INSTRUCTION")
@@ -80,6 +87,8 @@ func TestOpDoc(t *testing.T) {
}
func TestOpImmediateNote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
xd := OpImmediateNote("txn")
require.NotEmpty(t, xd)
xd = OpImmediateNote("+")
@@ -100,6 +109,8 @@ func TestAllImmediatesDocumented(t *testing.T) {
}
func TestOpDocExtra(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
xd := OpDocExtra("bnz")
require.NotEmpty(t, xd)
xd = OpDocExtra("-")
@@ -107,6 +118,8 @@ func TestOpDocExtra(t *testing.T) {
}
func TestOpAllCosts(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := OpAllCosts("+")
require.Len(t, a, 1)
require.Equal(t, 1, a[0].Cost)
@@ -119,6 +132,8 @@ func TestOpAllCosts(t *testing.T) {
}
func TestOnCompletionDescription(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
desc := OnCompletionDescription(0)
require.Equal(t, "Only execute the `ApprovalProgram` associated with this application ID, with no additional effects.", desc)
@@ -127,6 +142,8 @@ func TestOnCompletionDescription(t *testing.T) {
}
func TestFieldDocs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
txnFields := TxnFieldDocs()
require.Greater(t, len(txnFields), 0)
diff --git a/data/transactions/logic/eval.go b/data/transactions/logic/eval.go
index a0b0593cc..f5937bde1 100644
--- a/data/transactions/logic/eval.go
+++ b/data/transactions/logic/eval.go
@@ -1699,6 +1699,37 @@ func opDig(cx *evalContext) {
cx.stack = append(cx.stack, sv)
}
+func opCover(cx *evalContext) {
+ depth := int(cx.program[cx.pc+1])
+ topIdx := len(cx.stack) - 1
+ idx := topIdx - depth
+ // Need to check stack size explicitly here because checkArgs() doesn't understand cover
+ // so we can't expect our stack to be prechecked.
+ if idx < 0 {
+ cx.err = fmt.Errorf("cover %d with stack size = %d", depth, len(cx.stack))
+ return
+ }
+ sv := cx.stack[topIdx]
+ copy(cx.stack[idx+1:], cx.stack[idx:])
+ cx.stack[idx] = sv
+}
+
+func opUncover(cx *evalContext) {
+ depth := int(cx.program[cx.pc+1])
+ topIdx := len(cx.stack) - 1
+ idx := topIdx - depth
+ // Need to check stack size explicitly here because checkArgs() doesn't understand uncover
+ // so we can't expect our stack to be prechecked.
+ if idx < 0 {
+ cx.err = fmt.Errorf("uncover %d with stack size = %d", depth, len(cx.stack))
+ return
+ }
+
+ sv := cx.stack[idx]
+ copy(cx.stack[idx:], cx.stack[idx+1:])
+ cx.stack[topIdx] = sv
+}
+
func (cx *evalContext) assetHoldingEnumToValue(holding *basics.AssetHolding, field uint64) (sv stackValue, err error) {
switch AssetHoldingField(field) {
case AssetBalance:
diff --git a/data/transactions/logic/evalStateful_test.go b/data/transactions/logic/evalStateful_test.go
index 59fe92d9c..2cceb2a4f 100644
--- a/data/transactions/logic/evalStateful_test.go
+++ b/data/transactions/logic/evalStateful_test.go
@@ -29,6 +29,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type balanceRecord struct {
@@ -467,6 +468,8 @@ func (l *testLedger) GetDelta(txn *transactions.Transaction) (evalDelta basics.E
}
func TestEvalModes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// ed25519verify and err are tested separately below
@@ -728,6 +731,8 @@ pop
}
func TestBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
ep, ledger := makeSampleEnv()
@@ -793,6 +798,8 @@ func testApp(t *testing.T, program string, ep EvalParams, problems ...string) ba
}
func TestMinBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
ep, ledger := makeSampleEnv()
@@ -831,6 +838,8 @@ func TestMinBalance(t *testing.T) {
}
func TestAppCheckOptedIn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
txn := makeSampleTxn()
@@ -876,6 +885,8 @@ func TestAppCheckOptedIn(t *testing.T) {
}
func TestAppReadLocalState(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `int 2 // account idx
@@ -1023,6 +1034,8 @@ int 0
}
func TestAppReadGlobalState(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `int 0
@@ -1228,6 +1241,8 @@ int 1
`
func TestAssets(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for _, field := range AssetHoldingFieldNames {
if !strings.Contains(assetsTestProgram, field) {
@@ -1428,6 +1443,8 @@ func TestAppParams(t *testing.T) {
}
func TestAppLocalReadWriteDeleteErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
sourceRead := `intcblock 0 100 0x77 1
@@ -1545,6 +1562,8 @@ intc_1
}
func TestAppLocalStateReadWrite(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
ep := defaultEvalParams(nil, nil)
@@ -1820,6 +1839,8 @@ int 1
}
func TestAppGlobalReadWriteDeleteErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
sourceRead := `int 0
@@ -1899,6 +1920,8 @@ int 1
}
func TestAppGlobalReadWrite(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// check writing ints and bytes
@@ -2116,6 +2139,8 @@ byte 0x414c474f
}
func TestAppGlobalReadOtherApp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `int 2 // ForeignApps index
byte "mykey1"
@@ -2161,6 +2186,8 @@ byte "myval"
}
func TestBlankKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `
byte ""
@@ -2195,6 +2222,8 @@ int 7
}
func TestAppGlobalDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// check write/delete/read
@@ -2352,6 +2381,8 @@ int 1
}
func TestAppLocalDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// check write/delete/read
@@ -2564,6 +2595,8 @@ int 1
}
func TestEnumFieldErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ep := defaultEvalParams(nil, nil)
source := `txn Amount`
@@ -2656,6 +2689,8 @@ pop
}
func TestReturnTypes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Ensure all opcodes return values they supposed to according to the OpSpecs table
t.Parallel()
typeToArg := map[StackType]string{
@@ -2722,6 +2757,8 @@ func TestReturnTypes(t *testing.T) {
"gloads": "gloads 0",
"gaid": "gaid 0",
"dig": "dig 0",
+ "cover": "cover 0",
+ "uncover": "uncover 0",
"intc": "intcblock 0; intc 0",
"intc_0": "intcblock 0; intc_0",
"intc_1": "intcblock 0 0; intc_1",
@@ -2790,6 +2827,7 @@ func TestReturnTypes(t *testing.T) {
}
func TestRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
t.Parallel()
ep, _ := makeSampleEnv()
source := "global Round; int 1; >="
@@ -2797,6 +2835,7 @@ func TestRound(t *testing.T) {
}
func TestLatestTimestamp(t *testing.T) {
+ partitiontest.PartitionTest(t)
t.Parallel()
ep, _ := makeSampleEnv()
source := "global LatestTimestamp; int 1; >="
@@ -2804,6 +2843,7 @@ func TestLatestTimestamp(t *testing.T) {
}
func TestCurrentApplicationID(t *testing.T) {
+ partitiontest.PartitionTest(t)
t.Parallel()
ep, ledger := makeSampleEnv()
ledger.appID = basics.AppIndex(42)
@@ -2812,6 +2852,7 @@ func TestCurrentApplicationID(t *testing.T) {
}
func TestAppLoop(t *testing.T) {
+ partitiontest.PartitionTest(t)
t.Parallel()
ep, _ := makeSampleEnv()
diff --git a/data/transactions/logic/eval_test.go b/data/transactions/logic/eval_test.go
index c1b291b77..df1da45f8 100644
--- a/data/transactions/logic/eval_test.go
+++ b/data/transactions/logic/eval_test.go
@@ -35,6 +35,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// Note that most of the tests use defaultEvalProto/defaultEvalParams as evaluator version so that
@@ -101,6 +102,8 @@ func defaultEvalParamsWithVersion(sb *strings.Builder, txn *transactions.SignedT
}
func TestTooManyArgs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -118,6 +121,8 @@ func TestTooManyArgs(t *testing.T) {
}
func TestEmptyProgram(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
pass, err := Eval(nil, defaultEvalParams(nil, nil))
require.Error(t, err)
@@ -127,6 +132,8 @@ func TestEmptyProgram(t *testing.T) {
// TestMinTealVersionParamEval tests eval/check reading the MinTealVersion from the param
func TestMinTealVersionParamEvalCheck(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
params := defaultEvalParams(nil, nil)
version2 := uint64(rekeyingEnabledVersion)
@@ -146,6 +153,7 @@ func TestMinTealVersionParamEvalCheck(t *testing.T) {
}
func TestTxnFieldToTealValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
txn := transactions.Transaction{}
groupIndex := 0
@@ -192,6 +200,8 @@ func TestTxnFieldToTealValue(t *testing.T) {
}
func TestWrongProtoVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -215,6 +225,8 @@ func TestWrongProtoVersion(t *testing.T) {
}
func TestSimpleMath(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 2; int 3; + ;int 5;==", 1)
testAccepts(t, "int 22; int 3; - ;int 19;==", 1)
@@ -225,6 +237,8 @@ func TestSimpleMath(t *testing.T) {
}
func TestSha256EqArg(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -281,6 +295,8 @@ int 1000000
&&`
func TestTLHC(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -366,16 +382,22 @@ func TestTLHC(t *testing.T) {
}
func TestU64Math(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 0x1234567812345678; int 0x100000000; /; int 0x12345678; ==", 1)
}
func TestItob(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "byte 0x1234567812345678; int 0x1234567812345678; itob; ==", 1)
}
func TestBtoi(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 0x1234567812345678; byte 0x1234567812345678; btoi; ==", 1)
testAccepts(t, "int 0x34567812345678; byte 0x34567812345678; btoi; ==", 1)
@@ -387,11 +409,15 @@ func TestBtoi(t *testing.T) {
}
func TestBtoiTooLong(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0x1234567812345678; byte 0x1234567812345678aa; btoi; ==", 1)
}
func TestBnz(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `
int 1
@@ -422,6 +448,8 @@ pop
}
func TestV2Branches(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `
int 0
@@ -442,27 +470,37 @@ int 1
}
func TestReturn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; return; err", 2)
testRejects(t, "int 0; return; int 1", 2)
}
func TestSubUnderflow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 1; int 10; -; pop; int 1", 1)
}
func TestAddOverflow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0xf000000000000000; int 0x1111111111111111; +; pop; int 1", 1)
}
func TestMulOverflow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0x111111111; int 0x222222222; *; pop; int 1", 1)
}
func TestMulwImpl(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
high, low, err := opMulwImpl(1, 2)
require.NoError(t, err)
@@ -486,6 +524,8 @@ func TestMulwImpl(t *testing.T) {
}
func TestMulw(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `
int 0x111111111
@@ -506,6 +546,8 @@ int 1 // ret 1
}
func TestAddwImpl(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
carry, sum := opAddwImpl(1, 2)
require.Equal(t, uint64(0), carry)
@@ -525,6 +567,8 @@ func TestAddwImpl(t *testing.T) {
}
func TestAddw(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `
int 0xFFFFFFFFFFFFFFFF
@@ -545,6 +589,8 @@ int 1 // ret 1
}
func TestUint128(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
x := uint128(0, 3)
require.Equal(t, x.String(), "3")
x = uint128(0, 0)
@@ -558,6 +604,8 @@ func TestUint128(t *testing.T) {
}
func TestDivModw(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// 2:0 / 1:0 == 2r0 == 0:2,0:0
testAccepts(t, `int 2; int 0; int 1; int 0; divmodw;
@@ -601,6 +649,8 @@ func TestDivModw(t *testing.T) {
}
func TestWideMath(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// 2^64 = 18446744073709551616, we use a bunch of numbers close to that below
pattern := `
int %d
@@ -645,51 +695,71 @@ int 1
}
func TestDivZero(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0x11; int 0; /; pop; int 1", 1)
}
func TestModZero(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0x111111111; int 0; %; pop; int 1", 1)
}
func TestErr(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "err; int 1", 1)
}
func TestModSubMulOk(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 35; int 16; %; int 1; -; int 2; *; int 4; ==", 1)
}
func TestPop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; int 0; pop", 1)
}
func TestStackLeftover(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 1; int 1", 1)
}
func TestStackBytesLeftover(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "byte 0x10101010", 1)
}
func TestStackEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 1; int 1; pop; pop", 1)
}
func TestArgTooFar(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "arg_1; btoi", 1)
}
func TestIntcTooFar(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// Want to be super clear that intc_1 fails, whether an intcblock exists (but small) or not
testPanics(t, "intc_1", 1)
@@ -697,12 +767,16 @@ func TestIntcTooFar(t *testing.T) {
}
func TestBytecTooFar(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "bytec_1; btoi", 1)
testPanics(t, "byte 0x23; bytec_1; btoi", 1)
}
func TestTxnBadField(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
program := []byte{0x01, 0x31, 0x7f}
err := Check(program, defaultEvalParams(nil, nil))
@@ -738,6 +812,8 @@ func TestTxnBadField(t *testing.T) {
}
func TestGtxnBadIndex(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
program := []byte{0x01, 0x33, 0x1, 0x01}
err := Check(program, defaultEvalParams(nil, nil))
@@ -761,6 +837,8 @@ func TestGtxnBadIndex(t *testing.T) {
}
func TestGtxnBadField(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
program := []byte{0x01, 0x33, 0x0, 0x7f}
err := Check(program, defaultEvalParams(nil, nil))
@@ -800,6 +878,8 @@ func TestGtxnBadField(t *testing.T) {
}
func TestGlobalBadField(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
program := []byte{0x01, 0x32, 0x7f}
err := Check(program, defaultEvalParams(nil, nil))
@@ -819,6 +899,8 @@ func TestGlobalBadField(t *testing.T) {
}
func TestArg(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -915,6 +997,8 @@ const globalV5TestProgram = globalV4TestProgram + `
`
func TestGlobal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
type desc struct {
lastField GlobalField
@@ -995,6 +1079,8 @@ func TestGlobal(t *testing.T) {
}
func TestTypeEnum(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -1049,6 +1135,8 @@ int %s
}
func TestOnCompletionConstants(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// ensure all the OnCompetion values are in OnCompletionValues list
@@ -1410,6 +1498,8 @@ func makeSampleTxnGroup(txn transactions.SignedTxn) []transactions.SignedTxn {
}
func TestTxn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for _, txnField := range TxnFieldNames {
if !strings.Contains(testTxnProgramTextV4, txnField) {
@@ -1474,6 +1564,8 @@ func TestTxn(t *testing.T) {
}
func TestCachedTxIDs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
cachedTxnProg := `
gtxn 0 TxID
@@ -1545,6 +1637,8 @@ return
}
func TestGaid(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
checkCreatableIDProg := `
gaid 0
@@ -1612,6 +1706,8 @@ int 0
}
func TestGtxn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
gtxnTextV1 := `gtxn 1 Amount
int 42
@@ -1755,6 +1851,8 @@ func testLogic(t *testing.T, program string, v uint64, ep EvalParams, problems .
}
func TestTxna(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `txna Accounts 1
txna ApplicationArgs 0
@@ -1876,6 +1974,8 @@ txn Sender
// check empty values in ApplicationArgs and Account
func TestTxnaEmptyValues(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := `txna ApplicationArgs 0
btoi
@@ -1926,6 +2026,8 @@ global ZeroAddress
}
func TestBitOps(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `int 0x17
int 0x3e
@@ -1942,6 +2044,8 @@ int 0x310
}
func TestStringOps(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `byte 0x123456789abc
substring 1 3
@@ -1973,6 +2077,8 @@ int 0
}
func TestConsOverflow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
justfits := `byte 0xf000000000000000
dup; concat // 16
@@ -1990,6 +2096,8 @@ dup; concat // 4096
}
func TestSubstringFlop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// fails in compiler
testProg(t, `byte 0xf000000000000000
@@ -2023,6 +2131,8 @@ len`, 2)
}
func TestSubstringRange(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, `byte 0xf000000000000000
substring 2 99
@@ -2098,6 +2208,8 @@ func TestExtractFlop(t *testing.T) {
}
func TestLoadStore(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, `int 37
int 37
@@ -2117,6 +2229,8 @@ load 1
}
func TestLoadStore2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
progText := `int 2
int 3
@@ -2133,6 +2247,8 @@ int 5
}
func TestGload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// for simple app-call-only transaction groups
@@ -2331,6 +2447,8 @@ int 1`,
}
func TestGloads(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// Multiple app calls
@@ -2455,11 +2573,15 @@ byte 0xf00d
&&`
func TestCompares(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, testCompareProgramText, 1)
}
func TestKeccak256(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
/*
pip install sha3
@@ -2475,6 +2597,8 @@ byte 0xc195eca25a6f4c82bfba0287082ddb0d602ae9230f9cf1f1a40b68f8e2c41567
}
func TestSHA512_256(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
/*
pip cryptography
@@ -2494,6 +2618,8 @@ byte 0x98D2C31612EA500279B6753E5F6E780CA63EBA8274049664DAD66A2565ED1D2A
}
func TestSlowLogic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
fragment := `byte 0x666E6F7264; keccak256
byte 0xc195eca25a6f4c82bfba0287082ddb0d602ae9230f9cf1f1a40b68f8e2c41567; ==;`
@@ -2550,6 +2676,8 @@ func isNotPanic(t *testing.T, err error) {
}
func TestStackUnderflow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2571,6 +2699,8 @@ func TestStackUnderflow(t *testing.T) {
}
func TestWrongStackTypeRuntime(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2592,6 +2722,8 @@ func TestWrongStackTypeRuntime(t *testing.T) {
}
func TestEqMismatch(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2614,6 +2746,8 @@ int 1`, v)
}
func TestNeqMismatch(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2636,6 +2770,8 @@ int 1`, v)
}
func TestWrongStackTypeRuntime2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2658,6 +2794,8 @@ int 1`, v)
}
func TestIllegalOp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2684,6 +2822,8 @@ func TestIllegalOp(t *testing.T) {
}
func TestShortProgram(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2710,6 +2850,8 @@ int 1
}
func TestShortProgramTrue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
ops := testProg(t, `intcblock 1
intc 0
@@ -2724,6 +2866,8 @@ done:`, 2)
require.True(t, pass)
}
func TestShortBytecblock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2751,6 +2895,8 @@ func TestShortBytecblock(t *testing.T) {
}
func TestShortBytecblock2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
sources := []string{
"02260180fe83f88fe0bf80ff01aa",
@@ -2787,6 +2933,8 @@ func checkPanic(cx *evalContext) error {
}
func TestPanic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2841,6 +2989,8 @@ func TestPanic(t *testing.T) {
}
func TestProgramTooNew(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var program [12]byte
vlen := binary.PutUvarint(program[:], EvalMaxVersion+1)
@@ -2854,6 +3004,8 @@ func TestProgramTooNew(t *testing.T) {
}
func TestInvalidVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
program, err := hex.DecodeString("ffffffffffffffffffffffff")
require.NoError(t, err)
@@ -2867,6 +3019,8 @@ func TestInvalidVersion(t *testing.T) {
}
func TestProgramProtoForbidden(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var program [12]byte
vlen := binary.PutUvarint(program[:], EvalMaxVersion)
@@ -2885,6 +3039,8 @@ func TestProgramProtoForbidden(t *testing.T) {
}
func TestMisalignedBranch(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2928,6 +3084,8 @@ int 1`, v)
}
func TestBranchTooFar(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -2955,6 +3113,8 @@ int 1`, v)
}
func TestBranchTooLarge(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(1); v <= AssemblerMaxVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -3482,6 +3642,8 @@ func BenchmarkSha256Raw(b *testing.B) {
}
func TestEd25519verify(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var s crypto.Seed
crypto.RandBytes(s[:])
@@ -3613,6 +3775,8 @@ func BenchmarkCheckx5(b *testing.B) {
}
func TestStackValues(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
actual := oneInt.plus(oneInt)
@@ -3629,6 +3793,8 @@ func TestStackValues(t *testing.T) {
}
func TestEvalVersions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `intcblock 1
@@ -3658,6 +3824,8 @@ pop
}
func TestStackOverflow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
source := "int 1; int 2;"
for i := 1; i < MaxStackDepth/2; i++ {
@@ -3668,6 +3836,8 @@ func TestStackOverflow(t *testing.T) {
}
func TestDup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `int 1
@@ -3703,6 +3873,8 @@ int 1
}
func TestStringLiteral(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
text := `byte "foo bar"
@@ -3731,6 +3903,8 @@ byte 0x // empty byte constant
}
func TestArgType(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var sv stackValue
@@ -3744,6 +3918,8 @@ func TestArgType(t *testing.T) {
}
func TestApplicationsDisallowOldTeal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const source = "int 1"
ep := defaultEvalParams(nil, nil)
@@ -3777,6 +3953,8 @@ func TestApplicationsDisallowOldTeal(t *testing.T) {
}
func TestAnyRekeyToOrApplicationRaisesMinTealVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const source = "int 1"
// Construct a group of two payments, no rekeying
@@ -3869,6 +4047,8 @@ func TestAnyRekeyToOrApplicationRaisesMinTealVersion(t *testing.T) {
// check all v2 opcodes: allowed in v2 and not allowed in v1 and v0
func TestAllowedOpcodesV2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
tests := map[string]string{
@@ -3946,6 +4126,8 @@ func TestAllowedOpcodesV2(t *testing.T) {
// check all v3 opcodes: allowed in v3 and not allowed before
func TestAllowedOpcodesV3(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// all tests are expected to fail in evaluation
@@ -4005,6 +4187,8 @@ func TestAllowedOpcodesV3(t *testing.T) {
}
func TestRekeyFailsOnOldVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for v := uint64(0); v < rekeyingEnabledVersion; v++ {
t.Run(fmt.Sprintf("v=%d", v), func(t *testing.T) {
@@ -4106,6 +4290,8 @@ func testPanics(t *testing.T, program string, introduced uint64) error {
}
func TestAssert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1;assert;int 1", 3)
testRejects(t, "int 1;assert;int 0", 3)
@@ -4115,6 +4301,8 @@ func TestAssert(t *testing.T) {
}
func TestBits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; int 0; getbit; int 1; ==", 3)
testAccepts(t, "int 1; int 1; getbit; int 0; ==", 3)
@@ -4151,6 +4339,8 @@ func TestBits(t *testing.T) {
}
func TestBytes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "byte 0x12345678; int 2; getbyte; int 0x56; ==", 3)
testPanics(t, "byte 0x12345678; int 4; getbyte; int 0x56; ==", 3)
@@ -4183,12 +4373,16 @@ func TestMethod(t *testing.T) {
}
func TestSwap(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; byte 0x1234; swap; int 1; ==; assert; byte 0x1234; ==", 3)
testPanics(t, obfuscate("int 1; swap; int 1; return"), 3)
}
func TestSelect(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; byte 0x1231; int 0; select", 3) // selects the 1
@@ -4199,12 +4393,38 @@ func TestSelect(t *testing.T) {
}
func TestDig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 3; int 2; int 1; dig 1; int 2; ==; return", 3)
testPanics(t, obfuscate("int 3; int 2; int 1; dig 11; int 2; ==; return"), 3)
}
+func TestCover(t *testing.T) {
+ t.Parallel()
+ testAccepts(t, "int 4; int 3; int 2; int 1; cover 0; int 1; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; cover 1; int 2; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; cover 2; int 2; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; cover 2; pop; pop; int 1; ==; return", 5)
+ testPanics(t, obfuscate("int 4; int 3; int 2; int 1; cover 11; int 2; ==; return"), 5)
+ testPanics(t, obfuscate("int 4; int 3; int 2; int 1; cover 4; int 2; ==; return"), 5)
+}
+
+func TestUncover(t *testing.T) {
+ t.Parallel()
+ testAccepts(t, "int 4; int 3; int 2; int 1; uncover 0; int 1; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; uncover 2; int 3; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; uncover 3; int 4; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; uncover 3; pop; int 1; ==; return", 5)
+ testAccepts(t, "int 4; int 3; int 2; int 1; uncover 3; pop; pop; int 2; ==; return", 5)
+ testAccepts(t, "int 1; int 3; int 2; int 1; uncover 3; pop; pop; int 2; ==; return", 5)
+ testPanics(t, obfuscate("int 4; int 3; int 2; int 1; uncover 11; int 3; ==; return"), 5)
+ testPanics(t, obfuscate("int 4; int 3; int 2; int 1; uncover 4; int 2; ==; return"), 5)
+}
+
func TestPush(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 2; pushint 2; ==", 3)
testAccepts(t, "pushbytes 0x1234; byte 0x1234; ==", 3)
@@ -4232,6 +4452,8 @@ func TestPush(t *testing.T) {
}
func TestLoop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
// Double until > 10. Should be 16
testAccepts(t, "int 1; loop: int 2; *; dup; int 10; <; bnz loop; int 16; ==", 4)
@@ -4243,6 +4465,8 @@ func TestLoop(t *testing.T) {
}
func TestSubroutine(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; callsub double; int 2; ==; return; double: dup; +; retsub;", 4)
testAccepts(t, `
@@ -4325,6 +4549,8 @@ main:
}
func TestShifts(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 1; int 1; shl; int 2; ==", 4)
testAccepts(t, "int 1; int 2; shl; int 4; ==", 4)
@@ -4340,6 +4566,8 @@ func TestShifts(t *testing.T) {
}
func TestSqrt(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 0; sqrt; int 0; ==", 4)
testAccepts(t, "int 1; sqrt; int 1; ==", 4)
@@ -4364,6 +4592,8 @@ func TestSqrt(t *testing.T) {
}
func TestExp(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0; int 0; exp; int 1; ==", 4)
testAccepts(t, "int 0; int 200; exp; int 0; ==", 4)
@@ -4375,6 +4605,8 @@ func TestExp(t *testing.T) {
}
func TestExpw(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testPanics(t, "int 0; int 0; expw; int 1; ==; assert; int 0; ==", 4)
testAccepts(t, "int 0; int 200; expw; int 0; ==; assert; int 0; ==", 4)
@@ -4389,6 +4621,8 @@ func TestExpw(t *testing.T) {
}
func TestBitLen(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "int 0; bitlen; int 0; ==", 4)
testAccepts(t, "int 1; bitlen; int 1; ==", 4)
@@ -4410,6 +4644,8 @@ func TestBitLen(t *testing.T) {
}
func TestBytesMath(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "byte 0x01; byte 0x01; b+; byte 0x02; ==", 4)
testAccepts(t, "byte 0x01FF; byte 0x01; b+; byte 0x0200; ==", 4)
@@ -4438,6 +4674,8 @@ func TestBytesMath(t *testing.T) {
}
func TestBytesCompare(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "byte 0x10; byte 0x10; b*; byte 0x0100; ==", 4)
testAccepts(t, "byte 0x100000000000; byte 0x00; b*; byte b64(); ==", 4)
@@ -4461,6 +4699,8 @@ func TestBytesCompare(t *testing.T) {
}
func TestBytesBits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
testAccepts(t, "byte 0x11; byte 0x10; b|; byte 0x11; ==", 4)
testAccepts(t, "byte 0x01; byte 0x10; b|; byte 0x11; ==", 4)
@@ -4486,6 +4726,8 @@ func TestBytesBits(t *testing.T) {
}
func TestBytesConversions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccepts(t, "byte 0x11; byte 0x10; b+; btoi; int 0x21; ==", 4)
testAccepts(t, "byte 0x0011; byte 0x10; b+; btoi; int 0x21; ==", 4)
}
diff --git a/data/transactions/logic/opcodes.go b/data/transactions/logic/opcodes.go
index 50698e7b6..6350856c7 100644
--- a/data/transactions/logic/opcodes.go
+++ b/data/transactions/logic/opcodes.go
@@ -219,6 +219,8 @@ var OpSpecs = []OpSpec{
{0x4b, "dig", opDig, asmDefault, disDefault, oneAny, twoAny, 3, modeAny, stacky(typeDig, "n")},
{0x4c, "swap", opSwap, asmDefault, disDefault, twoAny, twoAny, 3, modeAny, stacky(typeSwap)},
{0x4d, "select", opSelect, asmDefault, disDefault, twoAny.plus(oneInt), oneAny, 3, modeAny, opDefault},
+ {0x4e, "cover", opCover, asmDefault, disDefault, oneAny, oneAny, 5, modeAny, stacky(typeCover, "n")},
+ {0x4f, "uncover", opUncover, asmDefault, disDefault, oneAny, oneAny, 5, modeAny, stacky(typeUncover, "n")},
{0x50, "concat", opConcat, asmDefault, disDefault, twoBytes, oneBytes, 2, modeAny, opDefault},
{0x51, "substring", opSubstring, assembleSubstring, disDefault, oneBytes, oneBytes, 2, modeAny, immediates("s", "e")},
diff --git a/data/transactions/logic/opcodes_test.go b/data/transactions/logic/opcodes_test.go
index 36dca364a..c894e1247 100644
--- a/data/transactions/logic/opcodes_test.go
+++ b/data/transactions/logic/opcodes_test.go
@@ -21,10 +21,13 @@ import (
"reflect"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestOpSpecs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
for _, spec := range OpSpecs {
@@ -56,6 +59,7 @@ func (os *OpSpec) equals(oso *OpSpec) bool {
}
func TestOpcodesByVersionReordered(t *testing.T) {
+ partitiontest.PartitionTest(t)
// Make a copy to restore to the original
OpSpecsOrig := make([]OpSpec, len(OpSpecs))
@@ -77,6 +81,8 @@ func TestOpcodesByVersionReordered(t *testing.T) {
}
func TestOpcodesByVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Make a copy of the OpSpecs to check if OpcodesByVersion will change it
OpSpecs2 := make([]OpSpec, len(OpSpecs))
for idx, opspec := range OpSpecs {
@@ -115,6 +121,8 @@ func TestOpcodesByVersion(t *testing.T) {
}
func TestOpcodesVersioningV2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
require.Equal(t, LogicVersion+1, len(opsByOpcode))
diff --git a/data/transactions/msgp_gen_test.go b/data/transactions/msgp_gen_test.go
index 5914a26cd..8c8697f18 100644
--- a/data/transactions/msgp_gen_test.go
+++ b/data/transactions/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalApplicationCallTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ApplicationCallTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalApplicationCallTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalApplyData(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := ApplyData{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalApplyData(b *testing.B) {
}
func TestMarshalUnmarshalAssetConfigTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AssetConfigTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -189,6 +193,7 @@ func BenchmarkUnmarshalAssetConfigTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalAssetFreezeTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AssetFreezeTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -248,6 +253,7 @@ func BenchmarkUnmarshalAssetFreezeTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalAssetTransferTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AssetTransferTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -307,6 +313,7 @@ func BenchmarkUnmarshalAssetTransferTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalCompactCertTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := CompactCertTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -366,6 +373,7 @@ func BenchmarkUnmarshalCompactCertTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalHeader(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Header{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -425,6 +433,7 @@ func BenchmarkUnmarshalHeader(b *testing.B) {
}
func TestMarshalUnmarshalKeyregTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := KeyregTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -484,6 +493,7 @@ func BenchmarkUnmarshalKeyregTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalLogicSig(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := LogicSig{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -543,6 +553,7 @@ func BenchmarkUnmarshalLogicSig(b *testing.B) {
}
func TestMarshalUnmarshalPaymentTxnFields(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := PaymentTxnFields{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -602,6 +613,7 @@ func BenchmarkUnmarshalPaymentTxnFields(b *testing.B) {
}
func TestMarshalUnmarshalPayset(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Payset{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -661,6 +673,7 @@ func BenchmarkUnmarshalPayset(b *testing.B) {
}
func TestMarshalUnmarshalSignedTxn(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := SignedTxn{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -720,6 +733,7 @@ func BenchmarkUnmarshalSignedTxn(b *testing.B) {
}
func TestMarshalUnmarshalSignedTxnInBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := SignedTxnInBlock{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -779,6 +793,7 @@ func BenchmarkUnmarshalSignedTxnInBlock(b *testing.B) {
}
func TestMarshalUnmarshalSignedTxnWithAD(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := SignedTxnWithAD{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -838,6 +853,7 @@ func BenchmarkUnmarshalSignedTxnWithAD(b *testing.B) {
}
func TestMarshalUnmarshalTransaction(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := Transaction{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -897,6 +913,7 @@ func BenchmarkUnmarshalTransaction(b *testing.B) {
}
func TestMarshalUnmarshalTxGroup(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := TxGroup{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/data/transactions/payment_test.go b/data/transactions/payment_test.go
index 082e9010e..7bdddd992 100644
--- a/data/transactions/payment_test.go
+++ b/data/transactions/payment_test.go
@@ -24,6 +24,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func keypair() *crypto.SignatureSecrets {
@@ -34,6 +35,8 @@ func keypair() *crypto.SignatureSecrets {
}
func TestAlgosEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var a basics.MicroAlgos
var b basics.MicroAlgos
var i uint64
diff --git a/data/transactions/payset_test.go b/data/transactions/payset_test.go
index 38539c228..9b8633b62 100644
--- a/data/transactions/payset_test.go
+++ b/data/transactions/payset_test.go
@@ -19,6 +19,7 @@ package transactions
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -35,6 +36,8 @@ func preparePayset(txnCount, acctCount int) Payset {
return Payset(stxnb)
}
func TestPaysetCommitsToTxnOrder(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
payset := preparePayset(50, 50)
commit1 := payset.CommitFlat()
payset[0], payset[1] = payset[1], payset[0]
@@ -43,6 +46,8 @@ func TestPaysetCommitsToTxnOrder(t *testing.T) {
}
func TestEmptyPaysetCommitment(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const nilFlatPaysetHash = "WRS2VL2OQ5LPWBYLNBCZV3MEQ4DACSRDES6IUKHGOWYQERJRWC5A"
const emptyFlatPaysetHash = "E54GFMNS2LISPG5VUGOQ3B2RR7TRKAHRE24LUM3HOW6TJGQ6PNZQ"
const merklePaysetHash = "4OYMIQUY7QOBJGX36TEJS35ZEQT24QPEMSNZGTFESWMRW6CSXBKQ"
diff --git a/data/transactions/signedtxn_test.go b/data/transactions/signedtxn_test.go
index 7375c8b77..9826c8f48 100644
--- a/data/transactions/signedtxn_test.go
+++ b/data/transactions/signedtxn_test.go
@@ -23,9 +23,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
secrets := keypair()
zeroPayment := Transaction{Type: protocol.PaymentTx}
zeroKeyReg := Transaction{Type: protocol.KeyRegistrationTx}
@@ -60,6 +63,8 @@ func TestEncoding(t *testing.T) {
}
func TestDecodeNil(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// This is a regression test for improper decoding of a nil SignedTxn.
// This is a subtle case because decoding a msgpack nil does not run
// SignedTxn.CodecDecodeSelf().
@@ -74,6 +79,8 @@ func TestDecodeNil(t *testing.T) {
}
func TestSignedTxnInBlockHash(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var stib SignedTxnInBlock
crypto.RandBytes(stib.Txn.Sender[:])
require.Equal(t, crypto.HashObj(&stib), stib.Hash())
diff --git a/data/transactions/transaction.go b/data/transactions/transaction.go
index c0e3e863f..552255796 100644
--- a/data/transactions/transaction.go
+++ b/data/transactions/transaction.go
@@ -344,6 +344,7 @@ func (tx Transaction) WellFormed(spec SpecialAddresses, proto config.ConsensusPa
}
}
+ effectiveEPP := tx.ExtraProgramPages
// Schemas and ExtraProgramPages may only be set during application creation
if tx.ApplicationID != 0 {
if tx.LocalStateSchema != (basics.StateSchema{}) ||
@@ -353,6 +354,11 @@ func (tx Transaction) WellFormed(spec SpecialAddresses, proto config.ConsensusPa
if tx.ExtraProgramPages != 0 {
return fmt.Errorf("tx.ExtraProgramPages is immutable")
}
+
+ if proto.EnableExtraPagesOnAppUpdate {
+ effectiveEPP = uint32(proto.MaxExtraAppProgramPages)
+ }
+
}
// Limit total number of arguments
@@ -396,7 +402,7 @@ func (tx Transaction) WellFormed(spec SpecialAddresses, proto config.ConsensusPa
lap := len(tx.ApprovalProgram)
lcs := len(tx.ClearStateProgram)
- pages := int(1 + tx.ExtraProgramPages)
+ pages := int(1 + effectiveEPP)
if lap > pages*proto.MaxAppProgramLen {
return fmt.Errorf("approval program too long. max len %d bytes", pages*proto.MaxAppProgramLen)
}
diff --git a/data/transactions/transaction_test.go b/data/transactions/transaction_test.go
index 5e8151467..72fe13b2f 100644
--- a/data/transactions/transaction_test.go
+++ b/data/transactions/transaction_test.go
@@ -26,10 +26,13 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestTransaction_EstimateEncodedSize(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
addr, err := basics.UnmarshalChecksumAddress("NDQCJNNY5WWWFLP4GFZ7MEF2QJSMZYK6OWIV2AQ7OMAVLEFCGGRHFPKJJA")
require.NoError(t, err)
@@ -80,6 +83,8 @@ func generateDummyGoNonparticpatingTransaction(addr basics.Address) (tx Transact
}
func TestGoOnlineGoNonparticipatingContradiction(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// addr has no significance here other than being a normal valid address
addr, err := basics.UnmarshalChecksumAddress("NDQCJNNY5WWWFLP4GFZ7MEF2QJSMZYK6OWIV2AQ7OMAVLEFCGGRHFPKJJA")
require.NoError(t, err)
@@ -102,6 +107,8 @@ func TestGoOnlineGoNonparticipatingContradiction(t *testing.T) {
}
func TestGoNonparticipatingWellFormed(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// addr has no significance here other than being a normal valid address
addr, err := basics.UnmarshalChecksumAddress("NDQCJNNY5WWWFLP4GFZ7MEF2QJSMZYK6OWIV2AQ7OMAVLEFCGGRHFPKJJA")
require.NoError(t, err)
@@ -124,6 +131,8 @@ func TestGoNonparticipatingWellFormed(t *testing.T) {
}
func TestAppCallCreateWellFormed(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
feeSink := basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21}
specialAddr := SpecialAddresses{FeeSink: feeSink}
curProto := config.Consensus[protocol.ConsensusCurrentVersion]
@@ -223,11 +232,14 @@ func TestAppCallCreateWellFormed(t *testing.T) {
}
func TestWellFormedErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
feeSink := basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21}
specialAddr := SpecialAddresses{FeeSink: feeSink}
curProto := config.Consensus[protocol.ConsensusCurrentVersion]
futureProto := config.Consensus[protocol.ConsensusFuture]
protoV27 := config.Consensus[protocol.ConsensusV27]
+ protoV28 := config.Consensus[protocol.ConsensusV28]
addr1, err := basics.UnmarshalChecksumAddress("NDQCJNNY5WWWFLP4GFZ7MEF2QJSMZYK6OWIV2AQ7OMAVLEFCGGRHFPKJJA")
require.NoError(t, err)
okHeader := Header{
@@ -447,6 +459,54 @@ func TestWellFormedErrors(t *testing.T) {
proto: futureProto,
expectedError: fmt.Errorf("tx has too many references, max is 8"),
},
+ {
+ tx: Transaction{
+ Type: protocol.ApplicationCallTx,
+ Header: okHeader,
+ ApplicationCallTxnFields: ApplicationCallTxnFields{
+ ApplicationID: 1,
+ ApprovalProgram: []byte(strings.Repeat("X", 1025)),
+ ClearStateProgram: []byte(strings.Repeat("X", 1025)),
+ ExtraProgramPages: 0,
+ OnCompletion: UpdateApplicationOC,
+ },
+ },
+ spec: specialAddr,
+ proto: protoV28,
+ expectedError: fmt.Errorf("app programs too long. max total len %d bytes", curProto.MaxAppProgramLen),
+ },
+ {
+ tx: Transaction{
+ Type: protocol.ApplicationCallTx,
+ Header: okHeader,
+ ApplicationCallTxnFields: ApplicationCallTxnFields{
+ ApplicationID: 1,
+ ApprovalProgram: []byte(strings.Repeat("X", 1025)),
+ ClearStateProgram: []byte(strings.Repeat("X", 1025)),
+ ExtraProgramPages: 0,
+ OnCompletion: UpdateApplicationOC,
+ },
+ },
+ spec: specialAddr,
+ proto: futureProto,
+ },
+ {
+ tx: Transaction{
+ Type: protocol.ApplicationCallTx,
+ Header: okHeader,
+ ApplicationCallTxnFields: ApplicationCallTxnFields{
+ ApplicationID: 1,
+ ApplicationArgs: [][]byte{
+ []byte("write"),
+ },
+ ExtraProgramPages: 1,
+ OnCompletion: UpdateApplicationOC,
+ },
+ },
+ spec: specialAddr,
+ proto: protoV28,
+ expectedError: fmt.Errorf("tx.ExtraProgramPages is immutable"),
+ },
}
for _, usecase := range usecases {
err := usecase.tx.WellFormed(usecase.spec, usecase.proto)
@@ -458,6 +518,8 @@ var generateFlag = flag.Bool("generate", false, "")
// running test with -generate would generate the matrix used in the test ( without the "correct" errors )
func TestWellFormedKeyRegistrationTx(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
flag.Parse()
// addr has no significance here other than being a normal valid address
diff --git a/data/transactions/verify/txn_test.go b/data/transactions/verify/txn_test.go
index a22cbcb27..36ac93637 100644
--- a/data/transactions/verify/txn_test.go
+++ b/data/transactions/verify/txn_test.go
@@ -30,6 +30,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/execpool"
)
@@ -106,6 +107,8 @@ func generateTestObjects(numTxs, numAccs int, blockRound basics.Round) ([]transa
}
func TestSignedPayment(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
payments, stxns, secrets, addrs := generateTestObjects(1, 1, 0)
@@ -127,6 +130,8 @@ func TestSignedPayment(t *testing.T) {
}
func TestTxnValidationEncodeDecode(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
_, signed, _, _ := generateTestObjects(100, 50, 0)
for _, txn := range signed {
@@ -147,6 +152,8 @@ func TestTxnValidationEncodeDecode(t *testing.T) {
}
func TestTxnValidationEmptySig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
_, signed, _, _ := generateTestObjects(100, 50, 0)
for _, txn := range signed {
@@ -168,6 +175,8 @@ func TestTxnValidationEmptySig(t *testing.T) {
const ccProto = protocol.ConsensusVersion("test-compact-cert-enabled")
func TestTxnValidationCompactCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
proto.CompactCertRounds = 128
config.Consensus[ccProto] = proto
@@ -236,6 +245,8 @@ func TestTxnValidationCompactCert(t *testing.T) {
}
func TestDecodeNil(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// This is a regression test for improper decoding of a nil SignedTxn.
// This is a subtle case because decoding a msgpack nil does not run
// SignedTxn.CodecDecodeSelf().
@@ -252,6 +263,8 @@ func TestDecodeNil(t *testing.T) {
}
func TestPaysetGroups(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
_, signedTxn, secrets, addrs := generateTestObjects(10000, 20, 50)
blkHdr := bookkeeping.BlockHeader{
Round: 50,
diff --git a/data/transactions/verify/verifiedTxnCache_test.go b/data/transactions/verify/verifiedTxnCache_test.go
index fe7a7ab75..db1cddec7 100644
--- a/data/transactions/verify/verifiedTxnCache_test.go
+++ b/data/transactions/verify/verifiedTxnCache_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestAddingToCache(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
icache := MakeVerifiedTransactionCache(500)
impl := icache.(*verifiedTransactionCache)
_, signedTxn, secrets, addrs := generateTestObjects(10, 5, 50)
@@ -43,6 +46,8 @@ func TestAddingToCache(t *testing.T) {
}
func TestBucketCycling(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
bucketCount := 3
icache := MakeVerifiedTransactionCache(entriesPerBucket * bucketCount)
impl := icache.(*verifiedTransactionCache)
@@ -71,6 +76,8 @@ func TestBucketCycling(t *testing.T) {
}
func TestGetUnverifiedTranscationGroups50(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
size := 300
icache := MakeVerifiedTransactionCache(size * 2)
impl := icache.(*verifiedTransactionCache)
@@ -127,6 +134,8 @@ func BenchmarkGetUnverifiedTranscationGroups50(b *testing.B) {
}
func TestUpdatePinned(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
size := entriesPerBucket
icache := MakeVerifiedTransactionCache(size * 10)
impl := icache.(*verifiedTransactionCache)
@@ -154,6 +163,8 @@ func TestUpdatePinned(t *testing.T) {
}
func TestPinningTransactions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
size := entriesPerBucket
icache := MakeVerifiedTransactionCache(size)
impl := icache.(*verifiedTransactionCache)
diff --git a/debug/doberman/main.go b/debug/doberman/main.go
index 0f447371e..e44609eb4 100644
--- a/debug/doberman/main.go
+++ b/debug/doberman/main.go
@@ -58,6 +58,9 @@ func main() {
// write logo
tf, err := ioutil.TempFile("", "algorand-logo.png")
+ if err != nil {
+ panic(err)
+ }
tfname = tf.Name()
defer func() {
time.Sleep(retireIn)
diff --git a/go.mod b/go.mod
index 72a697f54..f77970958 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ require (
github.com/algorand/go-codec/codec v0.0.0-20190507210007-269d70b6135d
github.com/algorand/go-deadlock v0.2.1
github.com/algorand/graphtrace v0.0.0-20201117160756-e524ed1a6f64
- github.com/algorand/msgp v1.1.47
+ github.com/algorand/msgp v1.1.48
github.com/algorand/oapi-codegen v1.3.5-algorand5
github.com/algorand/websocket v1.4.2
github.com/aws/aws-sdk-go v1.16.5
diff --git a/go.sum b/go.sum
index a7b101a48..1966c8ede 100644
--- a/go.sum
+++ b/go.sum
@@ -6,8 +6,8 @@ github.com/algorand/go-deadlock v0.2.1 h1:TQPQwWAB133bS5uwHpmrgH5hCMyZK5hnUW26aq
github.com/algorand/go-deadlock v0.2.1/go.mod h1:HgdF2cwtBIBCL7qmUaozuG/UIZFR6PLpSMR58pvWiXE=
github.com/algorand/graphtrace v0.0.0-20201117160756-e524ed1a6f64 h1:yvKeJdS/mvLRiyIxu8j5BQDXIzs1XbC9/22KycJnt3A=
github.com/algorand/graphtrace v0.0.0-20201117160756-e524ed1a6f64/go.mod h1:qFtQmC+kmsfnLfS9j3xgKtzsWyozemL5ek1R4dWZa5c=
-github.com/algorand/msgp v1.1.47 h1:xeU6G/Mb1iudJe4L5X38YrOY+VHhvHQDZXxyXYHTzOw=
-github.com/algorand/msgp v1.1.47/go.mod h1:LtOntbYiCHj/Sl/Sqxtf8CZOrDt2a8Dv3tLaS6mcnUE=
+github.com/algorand/msgp v1.1.48 h1:5P+gVmTnk0m37r+rA3ZsFZW219ZqmCLulW5f8Z+3nx8=
+github.com/algorand/msgp v1.1.48/go.mod h1:LtOntbYiCHj/Sl/Sqxtf8CZOrDt2a8Dv3tLaS6mcnUE=
github.com/algorand/oapi-codegen v1.3.5-algorand5 h1:y576Ca2/guQddQrQA7dtL5KcOx5xQgPeIupiuFMGyCI=
github.com/algorand/oapi-codegen v1.3.5-algorand5/go.mod h1:/k0Ywn0lnt92uBMyE+yiRf/Wo3/chxHHsAfenD09EbY=
github.com/algorand/websocket v1.4.2 h1:zMB7ukz+c7tcef8rVqmKQTv6KQtxXtCFuiAqKaE7n9I=
@@ -193,6 +193,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200423205358-59e73619c742 h1:9OGWpORUXvk8AsaBJlpzzDx7Srv/rSK6rvjcsJq4rJo=
golang.org/x/tools v0.0.0-20200423205358-59e73619c742/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/installer/algorand@.service.template b/installer/algorand@.service.template
index 5dda487b2..e74b29051 100644
--- a/installer/algorand@.service.template
+++ b/installer/algorand@.service.template
@@ -30,6 +30,7 @@ After=network.target
AssertPathExists=%I
[Service]
+ExecStartPre=bash -c "[[ ! -f %I/system.json ]] && echo '{\"shared_server\":true,\"systemd_managed\":true}' > %I/system.json || :"
ExecStart=@@BINDIR@@/algod -d %I
User=@@USER@@
Group=@@GROUP@@
diff --git a/ledger/accountdb_test.go b/ledger/accountdb_test.go
index 414a6a78a..30fad6f92 100644
--- a/ledger/accountdb_test.go
+++ b/ledger/accountdb_test.go
@@ -37,6 +37,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
@@ -428,6 +429,8 @@ func checkAccounts(t *testing.T, tx *sql.Tx, rnd basics.Round, accts map[basics.
}
func TestAccountDBInit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
dbs, _ := dbOpenTest(t, true)
@@ -519,6 +522,8 @@ func creatablesFromUpdates(base map[basics.Address]basics.AccountData, updates l
}
func TestAccountDBRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
dbs, _ := dbOpenTest(t, true)
@@ -944,6 +949,8 @@ func BenchmarkWritingRandomBalancesDisk(b *testing.B) {
require.NoError(b, err)
}
func TestAccountsReencoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
oldEncodedAccountsData := [][]byte{
{132, 164, 97, 108, 103, 111, 206, 5, 234, 236, 80, 164, 97, 112, 97, 114, 129, 206, 0, 3, 60, 164, 137, 162, 97, 109, 196, 32, 49, 54, 101, 102, 97, 97, 51, 57, 50, 52, 97, 54, 102, 100, 57, 100, 51, 97, 52, 56, 50, 52, 55, 57, 57, 97, 52, 97, 99, 54, 53, 100, 162, 97, 110, 167, 65, 80, 84, 75, 73, 78, 71, 162, 97, 117, 174, 104, 116, 116, 112, 58, 47, 47, 115, 111, 109, 101, 117, 114, 108, 161, 99, 196, 32, 183, 97, 139, 76, 1, 45, 180, 52, 183, 186, 220, 252, 85, 135, 185, 87, 156, 87, 158, 83, 49, 200, 133, 169, 43, 205, 26, 148, 50, 121, 28, 105, 161, 102, 196, 32, 183, 97, 139, 76, 1, 45, 180, 52, 183, 186, 220, 252, 85, 135, 185, 87, 156, 87, 158, 83, 49, 200, 133, 169, 43, 205, 26, 148, 50, 121, 28, 105, 161, 109, 196, 32, 60, 69, 244, 159, 234, 26, 168, 145, 153, 184, 85, 182, 46, 124, 227, 144, 84, 113, 176, 206, 109, 204, 245, 165, 100, 23, 71, 49, 32, 242, 146, 68, 161, 114, 196, 32, 183, 97, 139, 76, 1, 45, 180, 52, 183, 186, 220, 252, 85, 135, 185, 87, 156, 87, 158, 83, 49, 200, 133, 169, 43, 205, 26, 148, 50, 121, 28, 105, 161, 116, 205, 3, 32, 162, 117, 110, 163, 65, 80, 75, 165, 97, 115, 115, 101, 116, 129, 206, 0, 3, 60, 164, 130, 161, 97, 0, 161, 102, 194, 165, 101, 98, 97, 115, 101, 205, 98, 54},
{132, 164, 97, 108, 103, 111, 206, 5, 230, 217, 88, 164, 97, 112, 97, 114, 129, 206, 0, 3, 60, 175, 137, 162, 97, 109, 196, 32, 49, 54, 101, 102, 97, 97, 51, 57, 50, 52, 97, 54, 102, 100, 57, 100, 51, 97, 52, 56, 50, 52, 55, 57, 57, 97, 52, 97, 99, 54, 53, 100, 162, 97, 110, 167, 65, 80, 84, 75, 105, 110, 103, 162, 97, 117, 174, 104, 116, 116, 112, 58, 47, 47, 115, 111, 109, 101, 117, 114, 108, 161, 99, 196, 32, 111, 157, 243, 205, 146, 155, 167, 149, 44, 226, 153, 150, 6, 105, 206, 72, 182, 218, 38, 146, 98, 94, 57, 205, 145, 152, 12, 60, 175, 149, 94, 13, 161, 102, 196, 32, 111, 157, 243, 205, 146, 155, 167, 149, 44, 226, 153, 150, 6, 105, 206, 72, 182, 218, 38, 146, 98, 94, 57, 205, 145, 152, 12, 60, 175, 149, 94, 13, 161, 109, 196, 32, 60, 69, 244, 159, 234, 26, 168, 145, 153, 184, 85, 182, 46, 124, 227, 144, 84, 113, 176, 206, 109, 204, 245, 165, 100, 23, 71, 49, 32, 242, 146, 68, 161, 114, 196, 32, 111, 157, 243, 205, 146, 155, 167, 149, 44, 226, 153, 150, 6, 105, 206, 72, 182, 218, 38, 146, 98, 94, 57, 205, 145, 152, 12, 60, 175, 149, 94, 13, 161, 116, 205, 1, 44, 162, 117, 110, 164, 65, 80, 84, 75, 165, 97, 115, 115, 101, 116, 130, 206, 0, 3, 56, 153, 130, 161, 97, 10, 161, 102, 194, 206, 0, 3, 60, 175, 130, 161, 97, 0, 161, 102, 194, 165, 101, 98, 97, 115, 101, 205, 98, 54},
@@ -1031,6 +1038,8 @@ func TestAccountsReencoding(t *testing.T) {
// TestAccountsDbQueriesCreateClose tests to see that we can create the accountsDbQueries and close it.
// it also verify that double-closing it doesn't create an issue.
func TestAccountsDbQueriesCreateClose(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbs, _ := dbOpenTest(t, true)
setDbLogging(t, dbs)
defer dbs.Close()
@@ -1146,6 +1155,8 @@ func BenchmarkWriteCatchpointStagingBalances(b *testing.B) {
}
func TestCompactAccountDeltas(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ad := compactAccountDeltas{}
diff --git a/ledger/acctupdates.go b/ledger/acctupdates.go
index 9a82a8524..fd72cc75b 100644
--- a/ledger/acctupdates.go
+++ b/ledger/acctupdates.go
@@ -1602,7 +1602,6 @@ func (au *accountUpdates) deleteStoredCatchpoints(ctx context.Context, dbQueries
err = os.Remove(absCatchpointFileName)
if err == nil || os.IsNotExist(err) {
// it's ok if the file doesn't exist. just remove it from the database and we'll be good to go.
- err = nil
} else {
// we can't delete the file, abort -
return fmt.Errorf("unable to delete old catchpoint file '%s' : %v", absCatchpointFileName, err)
diff --git a/ledger/acctupdates_test.go b/ledger/acctupdates_test.go
index 925c3ce0e..54fd6d4f0 100644
--- a/ledger/acctupdates_test.go
+++ b/ledger/acctupdates_test.go
@@ -40,6 +40,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
@@ -309,6 +310,8 @@ func checkAcctUpdatesConsistency(t *testing.T, au *accountUpdates) {
}
func TestAcctUpdates(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}
@@ -393,6 +396,8 @@ func TestAcctUpdates(t *testing.T) {
}
func TestAcctUpdatesFastUpdates(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}
@@ -604,6 +609,8 @@ func BenchmarkCalibrateCacheNodeSize(b *testing.B) {
// and attempts to have the accountUpdates create the associated catchpoint. It's designed precisely around setting an
// environment which would quickly ( i.e. after 32 rounds ) would start producing catchpoints.
func TestLargeAccountCountCatchpointGeneration(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}
@@ -692,6 +699,8 @@ func TestLargeAccountCountCatchpointGeneration(t *testing.T) {
// In addition, throughout the test, we check ( using lookup ) that the historical balances, *beyond* the
// lookback are generating either an error, or returning the correct amount.
func TestAcctUpdatesUpdatesCorrectness(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}
@@ -866,6 +875,8 @@ func TestAcctUpdatesUpdatesCorrectness(t *testing.T) {
// and ensures that it did not errored, the catchpoint files were correctly deleted, and that deleteStoredCatchpoints contains no more
// entries.
func TestAcctUpdatesDeleteStoredCatchpoints(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
proto := config.Consensus[protocol.ConsensusCurrentVersion]
ml := makeMockLedgerForTracker(t, true, 10, protocol.ConsensusCurrentVersion)
@@ -1020,6 +1031,7 @@ func listAndCompare(t *testing.T,
// It tests with all elements in cache, all synced to database, and combination of both
// It also tests the max results, max app index and max asset index
func TestListCreatables(t *testing.T) {
+ partitiontest.PartitionTest(t)
// test configuration parameters
numElementsPerSegement := 25
@@ -1086,6 +1098,7 @@ func TestListCreatables(t *testing.T) {
}
func TestIsWritingCatchpointFile(t *testing.T) {
+ partitiontest.PartitionTest(t)
au := &accountUpdates{}
@@ -1099,6 +1112,7 @@ func TestIsWritingCatchpointFile(t *testing.T) {
}
func TestGetCatchpointStream(t *testing.T) {
+ partitiontest.PartitionTest(t)
proto := config.Consensus[protocol.ConsensusCurrentVersion]
@@ -1367,6 +1381,8 @@ func BenchmarkCompactDeltas(b *testing.B) {
})
}
func TestCompactDeltas(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
addrs := make([]basics.Address, 10)
for i := 0; i < len(addrs); i++ {
addrs[i] = basics.Address(crypto.Hash([]byte{byte(i % 256), byte((i / 256) % 256), byte(i / 65536)}))
@@ -1426,6 +1442,8 @@ func TestCompactDeltas(t *testing.T) {
}
func TestReproducibleCatchpointLabels(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
t.Skip("This test is too slow on ARM and causes travis builds to time out")
}
@@ -1548,6 +1566,8 @@ func TestReproducibleCatchpointLabels(t *testing.T) {
// TestCachesInitialization test the functionality of the initializeCaches cache.
func TestCachesInitialization(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
protocolVersion := protocol.ConsensusCurrentVersion
proto := config.Consensus[protocolVersion]
@@ -1640,6 +1660,8 @@ func TestCachesInitialization(t *testing.T) {
// TestSplittingConsensusVersionCommits tests the a sequence of commits that spans over multiple consensus versions works correctly.
func TestSplittingConsensusVersionCommits(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
initProtocolVersion := protocol.ConsensusV20
initialProtoParams := config.Consensus[initProtocolVersion]
@@ -1752,6 +1774,8 @@ func TestSplittingConsensusVersionCommits(t *testing.T) {
// TestSplittingConsensusVersionCommitsBoundry tests the a sequence of commits that spans over multiple consensus versions works correctly, and
// in particular, complements TestSplittingConsensusVersionCommits by testing the commit boundary.
func TestSplittingConsensusVersionCommitsBoundry(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
initProtocolVersion := protocol.ConsensusV20
initialProtoParams := config.Consensus[initProtocolVersion]
@@ -1895,6 +1919,8 @@ func TestSplittingConsensusVersionCommitsBoundry(t *testing.T) {
// TestConsecutiveVersion tests the consecutiveVersion method correctness.
func TestConsecutiveVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var au accountUpdates
au.versions = []protocol.ConsensusVersion{
protocol.ConsensusV19,
diff --git a/ledger/appcow.go b/ledger/appcow.go
index eafa0930f..4b41c92a5 100644
--- a/ledger/appcow.go
+++ b/ledger/appcow.go
@@ -222,7 +222,7 @@ func errAlreadyStorage(addr basics.Address, aidx basics.AppIndex, global bool) e
}
// Allocate creates kv storage for a given {addr, aidx, global}. It is called on app creation (global) or opting in (local)
-func (cb *roundCowState) Allocate(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error {
+func (cb *roundCowState) AllocateApp(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error {
// Check that account is not already opted in
allocated, err := cb.allocated(addr, aidx, global)
if err != nil {
@@ -241,11 +241,21 @@ func (cb *roundCowState) Allocate(addr basics.Address, aidx basics.AppIndex, glo
lsd.action = allocAction
lsd.maxCounts = &space
+ if global {
+ cb.mods.Creatables[basics.CreatableIndex(aidx)] = ledgercore.ModifiedCreatable{
+ Ctype: basics.AppCreatable,
+ Creator: addr,
+ Created: true,
+ }
+ }
+
+ cb.trackCreatable(basics.CreatableIndex(aidx))
+
return nil
}
// Deallocate clears storage for {addr, aidx, global}. It happens on app deletion (global) or closing out (local)
-func (cb *roundCowState) Deallocate(addr basics.Address, aidx basics.AppIndex, global bool) error {
+func (cb *roundCowState) DeallocateApp(addr basics.Address, aidx basics.AppIndex, global bool) error {
// Check that account has allocated storage
allocated, err := cb.allocated(addr, aidx, global)
if err != nil {
@@ -265,6 +275,15 @@ func (cb *roundCowState) Deallocate(addr basics.Address, aidx basics.AppIndex, g
lsd.counts = &basics.StateSchema{}
lsd.maxCounts = &basics.StateSchema{}
lsd.kvCow = make(stateDelta)
+
+ if global {
+ cb.mods.Creatables[basics.CreatableIndex(aidx)] = ledgercore.ModifiedCreatable{
+ Ctype: basics.AppCreatable,
+ Creator: addr,
+ Created: false,
+ }
+ }
+
return nil
}
@@ -619,7 +638,7 @@ func applyStorageDelta(data basics.AccountData, aapp storagePtr, store *storageD
delete(owned, aapp.aidx)
case allocAction, remainAllocAction:
// note: these should always exist because they were
- // at least preceded by a call to PutWithCreatable
+ // at least preceded by a call to Put()
params, ok := owned[aapp.aidx]
if !ok {
return basics.AccountData{}, fmt.Errorf("could not find existing params for %v", aapp.aidx)
diff --git a/ledger/appcow_test.go b/ledger/appcow_test.go
index 75dbfac91..7eb467dcc 100644
--- a/ledger/appcow_test.go
+++ b/ledger/appcow_test.go
@@ -30,6 +30,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type addrApp struct {
@@ -189,6 +190,8 @@ func randomAddrApps(n int) ([]storagePtr, []basics.Address) {
}
func TestCowStorage(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ml := emptyLedger{}
var bh bookkeeping.BlockHeader
bh.CurrentProtocol = protocol.ConsensusCurrentVersion
@@ -239,7 +242,7 @@ func TestCowStorage(t *testing.T) {
NumUint: rand.Uint64(),
NumByteSlice: rand.Uint64(),
}
- err := cow.Allocate(addr, sptr.aidx, sptr.global, rschema)
+ err := cow.AllocateApp(addr, sptr.aidx, sptr.global, rschema)
if actuallyAllocated {
require.Error(t, err)
require.Contains(t, err.Error(), "cannot allocate")
@@ -253,7 +256,7 @@ func TestCowStorage(t *testing.T) {
// Deallocate
if rand.Float32() < 0.25 {
actuallyAllocated := st.allocated(aapp)
- err := cow.Deallocate(addr, sptr.aidx, sptr.global)
+ err := cow.DeallocateApp(addr, sptr.aidx, sptr.global)
if actuallyAllocated {
require.NoError(t, err)
err := st.dealloc(aapp)
@@ -354,6 +357,8 @@ func TestCowStorage(t *testing.T) {
}
func TestCowBuildDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := randomAddress()
@@ -597,6 +602,8 @@ func TestCowBuildDelta(t *testing.T) {
}
func TestCowDeltaSerialize(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
d := stateDelta{
@@ -663,6 +670,8 @@ func TestCowDeltaSerialize(t *testing.T) {
}
func TestApplyChild(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
emptyStorageDelta := func(action storageAction) storageDelta {
@@ -793,6 +802,8 @@ func TestApplyChild(t *testing.T) {
}
func TestApplyStorageDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
created := valueDelta{
@@ -921,6 +932,8 @@ func TestApplyStorageDelta(t *testing.T) {
}
func TestCowAllocated(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
aidx := basics.AppIndex(1)
@@ -948,6 +961,8 @@ func TestCowAllocated(t *testing.T) {
}
func TestCowGetCreator(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -969,6 +984,8 @@ func TestCowGetCreator(t *testing.T) {
}
func TestCowGetters(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -985,6 +1002,8 @@ func TestCowGetters(t *testing.T) {
}
func TestCowGet(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -1008,6 +1027,8 @@ func TestCowGet(t *testing.T) {
}
func TestCowGetKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -1079,6 +1100,8 @@ func TestCowGetKey(t *testing.T) {
}
func TestCowSetKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -1172,6 +1195,8 @@ func TestCowSetKey(t *testing.T) {
}
func TestCowSetKeyVFuture(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -1205,6 +1230,8 @@ func TestCowSetKeyVFuture(t *testing.T) {
}
func TestCowAccountIdx(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
l := emptyLedger{}
@@ -1251,6 +1278,8 @@ func TestCowAccountIdx(t *testing.T) {
}
func TestCowDelKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
diff --git a/ledger/applications_test.go b/ledger/applications_test.go
index 5d1ec743a..14bdec0c7 100644
--- a/ledger/applications_test.go
+++ b/ledger/applications_test.go
@@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func getRandomAddress(a *require.Assertions) basics.Address {
@@ -135,6 +136,8 @@ func newCowMock(creatables []modsData) *mockCowForLogicLedger {
}
func TestLogicLedgerMake(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
_, err := newLogicLedger(nil, 0)
@@ -162,6 +165,8 @@ func TestLogicLedgerMake(t *testing.T) {
}
func TestLogicLedgerBalances(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -180,6 +185,8 @@ func TestLogicLedgerBalances(t *testing.T) {
}
func TestLogicLedgerGetters(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -206,6 +213,8 @@ func TestLogicLedgerGetters(t *testing.T) {
}
func TestLogicLedgerAsset(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -249,6 +258,8 @@ func TestLogicLedgerAsset(t *testing.T) {
}
func TestLogicLedgerGetKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -290,6 +301,8 @@ func TestLogicLedgerGetKey(t *testing.T) {
}
func TestLogicLedgerSetKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -318,6 +331,8 @@ func TestLogicLedgerSetKey(t *testing.T) {
}
func TestLogicLedgerDelKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
addr := getRandomAddress(a)
@@ -350,6 +365,8 @@ func TestLogicLedgerDelKey(t *testing.T) {
// 2) writing into empty (opted-in) local state's KeyValue works after reloading
// Hardcoded values are from commit 9a0b439 (pre app refactor commit)
func TestAppAccountDataStorage(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
source := `#pragma version 2
// do not write local key on opt in or on app create
@@ -575,6 +592,8 @@ return`
}
func TestAppAccountDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
source := `#pragma version 2
txn ApplicationID
@@ -852,6 +871,8 @@ return`
}
func TestAppEmptyAccountsLocal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
source := `#pragma version 2
txn ApplicationID
@@ -1002,6 +1023,8 @@ return`
}
func TestAppEmptyAccountsGlobal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
source := `#pragma version 2
txn ApplicationID
@@ -1133,6 +1156,8 @@ return`
}
func TestAppAccountDeltaIndicesCompatibility1(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
source := `#pragma version 2
txn ApplicationID
int 0
@@ -1154,6 +1179,8 @@ int 1
}
func TestAppAccountDeltaIndicesCompatibility2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
source := `#pragma version 2
txn ApplicationID
int 0
@@ -1175,6 +1202,8 @@ int 1
}
func TestAppAccountDeltaIndicesCompatibility3(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
source := `#pragma version 2
txn ApplicationID
int 0
diff --git a/ledger/apply/application.go b/ledger/apply/application.go
index dc9da3122..99e4fc3d6 100644
--- a/ledger/apply/application.go
+++ b/ledger/apply/application.go
@@ -121,21 +121,14 @@ func createApplication(ac *transactions.ApplicationCallTxnFields, balances Balan
totalExtraPages += ac.ExtraProgramPages
record.TotalExtraAppPages = totalExtraPages
- // Tell the cow what app we created
- created := &basics.CreatableLocator{
- Creator: creator,
- Type: basics.AppCreatable,
- Index: basics.CreatableIndex(appIdx),
- }
-
// Write back to the creator's balance record
- err = balances.PutWithCreatable(creator, record, created, nil)
+ err = balances.Put(creator, record)
if err != nil {
return 0, err
}
// Allocate global storage
- err = balances.Allocate(creator, appIdx, true, ac.GlobalStateSchema)
+ err = balances.AllocateApp(creator, appIdx, true, ac.GlobalStateSchema)
if err != nil {
return 0, err
}
@@ -169,19 +162,13 @@ func deleteApplication(balances Balances, creator basics.Address, appIdx basics.
record.TotalExtraAppPages = totalExtraPages
}
- // Tell the cow what app we deleted
- deleted := &basics.CreatableLocator{
- Creator: creator,
- Type: basics.AppCreatable,
- Index: basics.CreatableIndex(appIdx),
- }
- err = balances.PutWithCreatable(creator, record, nil, deleted)
+ err = balances.Put(creator, record)
if err != nil {
return err
}
// Deallocate global storage
- err = balances.Deallocate(creator, appIdx, true)
+ err = balances.DeallocateApp(creator, appIdx, true)
if err != nil {
return err
}
@@ -199,6 +186,16 @@ func updateApplication(ac *transactions.ApplicationCallTxnFields, balances Balan
// Fill in the new programs
record.AppParams = cloneAppParams(record.AppParams)
params := record.AppParams[appIdx]
+ proto := balances.ConsensusParams()
+ // when proto.EnableExtraPageOnAppUpdate is false, WellFormed rejects all updates with a multiple-page program
+ if proto.EnableExtraPagesOnAppUpdate {
+ allowed := int(1+params.ExtraProgramPages) * proto.MaxAppProgramLen
+ actual := len(ac.ApprovalProgram) + len(ac.ClearStateProgram)
+ if actual > allowed {
+ return fmt.Errorf("updateApplication app programs too long, %d. max total len %d bytes", actual, allowed)
+ }
+ }
+
params.ApprovalProgram = ac.ApprovalProgram
params.ClearStateProgram = ac.ClearStateProgram
@@ -243,7 +240,7 @@ func optInApplication(balances Balances, sender basics.Address, appIdx basics.Ap
}
// Allocate local storage
- err = balances.Allocate(sender, appIdx, false, params.LocalStateSchema)
+ err = balances.AllocateApp(sender, appIdx, false, params.LocalStateSchema)
if err != nil {
return err
}
@@ -281,7 +278,7 @@ func closeOutApplication(balances Balances, sender basics.Address, appIdx basics
}
// Deallocate local storage
- err = balances.Deallocate(sender, appIdx, false)
+ err = balances.DeallocateApp(sender, appIdx, false)
if err != nil {
return err
}
diff --git a/ledger/apply/application_test.go b/ledger/apply/application_test.go
index 0633db8d1..e47e82484 100644
--- a/ledger/apply/application_test.go
+++ b/ledger/apply/application_test.go
@@ -30,9 +30,12 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestApplicationCallFieldsEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ac := transactions.ApplicationCallTxnFields{}
@@ -103,11 +106,9 @@ type testBalances struct {
proto config.ConsensusParams
put int // Put calls counter
- putWith int // PutWithCreatable calls counter
putBalances map[basics.Address]basics.AccountData
- putWithBalances map[basics.Address]basics.AccountData
- putWithNew []basics.CreatableLocator
- putWithDel []basics.CreatableLocator
+ createdCreatables []basics.CreatableLocator
+ deletedCreatables []basics.CreatableLocator
allocatedAppIdx basics.AppIndex
deAllocatedAppIdx basics.AppIndex
@@ -141,21 +142,6 @@ func (b *testBalances) Put(addr basics.Address, ad basics.AccountData) error {
return nil
}
-func (b *testBalances) PutWithCreatable(addr basics.Address, ad basics.AccountData, newCreatable *basics.CreatableLocator, deletedCreatable *basics.CreatableLocator) error {
- b.putWith++
- if b.putWithBalances == nil {
- b.putWithBalances = make(map[basics.Address]basics.AccountData)
- }
- b.putWithBalances[addr] = ad
- if newCreatable != nil {
- b.putWithNew = append(b.putWithNew, *newCreatable)
- }
- if deletedCreatable != nil {
- b.putWithDel = append(b.putWithDel, *deletedCreatable)
- }
- return nil
-}
-
func (b *testBalances) GetCreator(cidx basics.CreatableIndex, ctype basics.CreatableType) (basics.Address, bool, error) {
if ctype == basics.AppCreatable {
aidx := basics.AppIndex(cidx)
@@ -176,13 +162,60 @@ func (b *testBalances) Move(src, dst basics.Address, amount basics.MicroAlgos, s
func (b *testBalances) ConsensusParams() config.ConsensusParams {
return b.proto
}
-func (b *testBalances) Allocate(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error {
+
+func (b *testBalances) AllocateApp(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error {
b.allocatedAppIdx = aidx
+
+ if global {
+ locator := basics.CreatableLocator{
+ Type: basics.AppCreatable,
+ Creator: addr,
+ Index: basics.CreatableIndex(aidx),
+ }
+ b.createdCreatables = append(b.createdCreatables, locator)
+ }
+
return nil
}
-func (b *testBalances) Deallocate(addr basics.Address, aidx basics.AppIndex, global bool) error {
+func (b *testBalances) DeallocateApp(addr basics.Address, aidx basics.AppIndex, global bool) error {
b.deAllocatedAppIdx = aidx
+
+ if global {
+ locator := basics.CreatableLocator{
+ Type: basics.AppCreatable,
+ Creator: addr,
+ Index: basics.CreatableIndex(aidx),
+ }
+ b.deletedCreatables = append(b.deletedCreatables, locator)
+ }
+
+ return nil
+}
+
+func (b *testBalances) AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ if global {
+ locator := basics.CreatableLocator{
+ Type: basics.AppCreatable,
+ Creator: addr,
+ Index: basics.CreatableIndex(index),
+ }
+ b.createdCreatables = append(b.createdCreatables, locator)
+ }
+
+ return nil
+}
+
+func (b *testBalances) DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ if global {
+ locator := basics.CreatableLocator{
+ Type: basics.AppCreatable,
+ Creator: addr,
+ Index: basics.CreatableIndex(index),
+ }
+ b.deletedCreatables = append(b.deletedCreatables, locator)
+ }
+
return nil
}
@@ -206,14 +239,6 @@ func (b *testBalancesPass) Put(addr basics.Address, ad basics.AccountData) error
return nil
}
-func (b *testBalancesPass) PutWithCreatable(addr basics.Address, ad basics.AccountData, newCreatable *basics.CreatableLocator, deletedCreatable *basics.CreatableLocator) error {
- if b.balances == nil {
- b.balances = make(map[basics.Address]basics.AccountData)
- }
- b.balances[addr] = ad
- return nil
-}
-
func (b *testBalancesPass) ConsensusParams() config.ConsensusParams {
return b.proto
}
@@ -230,14 +255,12 @@ func (b *testBalancesPass) StatefulEval(params logic.EvalParams, aidx basics.App
return true, b.delta, nil
}
-// ResetWrites clears side effects of Put/PutWithCreatable
+// ResetWrites clears side effects of Put.
func (b *testBalances) ResetWrites() {
b.put = 0
- b.putWith = 0
b.putBalances = nil
- b.putWithBalances = nil
- b.putWithNew = []basics.CreatableLocator{}
- b.putWithDel = []basics.CreatableLocator{}
+ b.createdCreatables = []basics.CreatableLocator{}
+ b.deletedCreatables = []basics.CreatableLocator{}
b.allocatedAppIdx = 0
}
@@ -273,6 +296,8 @@ func (e *testEvaluator) InitLedger(balances Balances, appIdx basics.AppIndex, sc
}
func TestAppCallCloneEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var ls map[basics.AppIndex]basics.AppLocalState
@@ -285,6 +310,8 @@ func TestAppCallCloneEmpty(t *testing.T) {
}
func TestAppCallGetParam(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var b testBalances
@@ -323,6 +350,8 @@ func TestAppCallGetParam(t *testing.T) {
}
func TestAppCallAddressByIndex(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
sender := getRandomAddress(a)
@@ -348,6 +377,8 @@ func TestAppCallAddressByIndex(t *testing.T) {
}
func TestAppCallCheckPrograms(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var ac transactions.ApplicationCallTxnFields
@@ -386,6 +417,8 @@ func TestAppCallCheckPrograms(t *testing.T) {
}
func TestAppCallCreate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var b testBalances
@@ -411,11 +444,8 @@ func TestAppCallCreate(t *testing.T) {
appIdx, err = createApplication(&ac, &b, creator, txnCounter)
a.NoError(err)
a.Equal(txnCounter+1, uint64(appIdx))
- a.Equal(0, b.put)
- a.Equal(1, b.putWith)
+ a.Equal(1, b.put)
nbr, ok := b.putBalances[creator]
- a.False(ok)
- nbr, ok = b.putWithBalances[creator]
a.True(ok)
params, ok := nbr.AppParams[appIdx]
a.True(ok)
@@ -423,11 +453,13 @@ func TestAppCallCreate(t *testing.T) {
a.Equal(ac.ClearStateProgram, params.ClearStateProgram)
a.Equal(ac.LocalStateSchema, params.LocalStateSchema)
a.Equal(ac.GlobalStateSchema, params.GlobalStateSchema)
- a.True(len(b.putWithNew) > 0)
+ a.Equal(1, len(b.createdCreatables))
}
// TestAppCallApplyCreate carefully tracks and validates balance record updates
func TestAppCallApplyCreate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -448,7 +480,6 @@ func TestAppCallApplyCreate(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "ApplicationCall cannot have nil ApplyData")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
b.balances = make(map[basics.Address]basics.AccountData)
b.balances[creator] = basics.AccountData{}
@@ -458,7 +489,6 @@ func TestAppCallApplyCreate(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "max created apps per acct is 0")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
b.SetProto(protocol.ConsensusFuture)
proto := b.ConsensusParams()
@@ -470,14 +500,13 @@ func TestAppCallApplyCreate(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.Error(err)
a.Contains(err.Error(), "applications that do not exist")
- a.Equal(0, b.put)
- a.Equal(1, b.putWith)
+ a.Equal(1, b.put)
appIdx := basics.AppIndex(txnCounter + 1)
b.appCreators = map[basics.AppIndex]basics.Address{appIdx: creator}
// save the created app info to the side
- saved := b.putWithBalances[creator]
+ saved := b.putBalances[creator]
b.ResetWrites()
@@ -486,8 +515,7 @@ func TestAppCallApplyCreate(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.Error(err)
a.Contains(err.Error(), fmt.Sprintf("app %d not found in account", appIdx))
- a.Equal(0, b.put)
- a.Equal(1, b.putWith)
+ a.Equal(1, b.put)
b.ResetWrites()
@@ -500,15 +528,14 @@ func TestAppCallApplyCreate(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "transaction rejected by ApprovalProgram")
a.Equal(uint64(b.allocatedAppIdx), txnCounter+1)
- a.Equal(0, b.put)
- a.Equal(1, b.putWith)
+ a.Equal(1, b.put)
// ensure original balance record in the mock was not changed
// this ensure proper cloning and any in-intended in-memory modifications
//
// known artefact of cloning AppLocalState even with empty update, nil map vs empty map
saved.AppLocalStates = map[basics.AppIndex]basics.AppLocalState{}
a.Equal(saved, b.balances[creator])
- saved = b.putWithBalances[creator]
+ saved = b.putBalances[creator]
b.ResetWrites()
@@ -523,10 +550,9 @@ func TestAppCallApplyCreate(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(appIdx, b.allocatedAppIdx)
- a.Equal(0, b.put)
- a.Equal(1, b.putWith)
+ a.Equal(1, b.put)
a.Equal(saved, b.balances[creator])
- br := b.putWithBalances[creator]
+ br := b.putBalances[creator]
a.Equal([]byte{1}, br.AppParams[appIdx].ApprovalProgram)
a.Equal([]byte{1}, br.AppParams[appIdx].ClearStateProgram)
a.Equal(basics.TealKeyValue(nil), br.AppParams[appIdx].GlobalState)
@@ -538,13 +564,15 @@ func TestAppCallApplyCreate(t *testing.T) {
ac.ExtraProgramPages = 1
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
- br = b.putWithBalances[creator]
+ br = b.putBalances[creator]
a.Equal(uint32(1), br.AppParams[appIdx].ExtraProgramPages)
a.Equal(uint32(1), br.TotalExtraAppPages)
}
// TestAppCallApplyCreateOptIn checks balance record fields without tracking substages
func TestAppCallApplyCreateOptIn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -590,6 +618,8 @@ func TestAppCallApplyCreateOptIn(t *testing.T) {
}
func TestAppCallOptIn(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
sender := getRandomAddress(a)
@@ -606,13 +636,11 @@ func TestAppCallOptIn(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "cannot opt in app")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
b.SetProto(protocol.ConsensusFuture)
err = optInApplication(&b, sender, appIdx, params)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br := b.putBalances[sender]
a.Equal(basics.AccountData{AppLocalStates: map[basics.AppIndex]basics.AppLocalState{appIdx: {}}}, br)
@@ -625,7 +653,6 @@ func TestAppCallOptIn(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "has already opted in to app")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
b.ResetWrites()
@@ -635,7 +662,6 @@ func TestAppCallOptIn(t *testing.T) {
err = optInApplication(&b, sender, appIdx, params)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
b.ResetWrites()
@@ -648,7 +674,6 @@ func TestAppCallOptIn(t *testing.T) {
err = optInApplication(&b, sender, appIdx, params)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br = b.putBalances[sender]
a.Equal(
basics.AccountData{
@@ -663,6 +688,8 @@ func TestAppCallOptIn(t *testing.T) {
}
func TestAppCallClearState(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -707,7 +734,6 @@ func TestAppCallClearState(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "is not currently opted in to app")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
// check non-existing app with empty opt-in
b.balances[sender] = basics.AccountData{
@@ -716,7 +742,6 @@ func TestAppCallClearState(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br := b.putBalances[sender]
a.Equal(0, len(br.AppLocalStates))
a.Equal(basics.StateSchema{}, br.TotalAppSchema)
@@ -735,7 +760,6 @@ func TestAppCallClearState(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br = b.putBalances[sender]
a.Equal(0, len(br.AppLocalStates))
a.Equal(basics.StateSchema{}, br.TotalAppSchema)
@@ -762,7 +786,6 @@ func TestAppCallClearState(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br = b.putBalances[sender]
a.Equal(0, len(br.AppLocalStates))
a.Equal(basics.StateSchema{}, br.TotalAppSchema)
@@ -778,7 +801,6 @@ func TestAppCallClearState(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br = b.putBalances[sender]
a.Equal(0, len(br.AppLocalStates))
a.Equal(basics.StateSchema{}, br.TotalAppSchema)
@@ -809,7 +831,6 @@ func TestAppCallClearState(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
a.Equal(appIdx, b.deAllocatedAppIdx)
a.Equal(0, len(br.AppLocalStates))
a.Equal(basics.StateSchema{}, br.TotalAppSchema)
@@ -817,6 +838,8 @@ func TestAppCallClearState(t *testing.T) {
}
func TestAppCallApplyCloseOut(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -860,7 +883,6 @@ func TestAppCallApplyCloseOut(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "transaction rejected by ApprovalProgram")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
br := b.balances[creator]
a.Equal(cbr, br)
a.Equal(basics.EvalDelta{}, ad.EvalDelta)
@@ -872,7 +894,6 @@ func TestAppCallApplyCloseOut(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "is not opted in to app")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
br = b.balances[creator]
a.Equal(cbr, br)
a.Equal(basics.EvalDelta{}, ad.EvalDelta)
@@ -888,7 +909,6 @@ func TestAppCallApplyCloseOut(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br = b.putBalances[creator]
a.NotEqual(cbr, br)
a.Equal(basics.TealKeyValue(nil), br.AppParams[appIdx].GlobalState)
@@ -896,9 +916,12 @@ func TestAppCallApplyCloseOut(t *testing.T) {
a.Equal(0, len(br.AppLocalStates))
a.Equal(basics.EvalDelta{GlobalDelta: gd}, ad.EvalDelta)
a.Equal(basics.StateSchema{NumUint: 0}, br.TotalAppSchema)
+
}
func TestAppCallApplyUpdate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -935,7 +958,7 @@ func TestAppCallApplyUpdate(t *testing.T) {
b.balances[creator] = cp
b.appCreators = map[basics.AppIndex]basics.Address{appIdx: creator}
- b.SetProto(protocol.ConsensusFuture)
+ b.SetProto(protocol.ConsensusV28)
proto := b.ConsensusParams()
ep.Proto = &proto
@@ -944,7 +967,6 @@ func TestAppCallApplyUpdate(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "transaction rejected by ApprovalProgram")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
br := b.balances[creator]
a.Equal(cbr, br)
a.Equal(basics.EvalDelta{}, ad.EvalDelta)
@@ -955,16 +977,78 @@ func TestAppCallApplyUpdate(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(1, b.put)
- a.Equal(0, b.putWith)
br = b.balances[creator]
a.Equal(cbr, br)
br = b.putBalances[creator]
a.Equal([]byte{2}, br.AppParams[appIdx].ApprovalProgram)
a.Equal([]byte{2}, br.AppParams[appIdx].ClearStateProgram)
a.Equal(basics.EvalDelta{}, ad.EvalDelta)
+
+ // check app program len
+ appr := make([]byte, 6050)
+
+ for i := range appr {
+ appr[i] = 2
+ }
+ appr[0] = 4
+ ac = transactions.ApplicationCallTxnFields{
+ ApplicationID: appIdx,
+ OnCompletion: transactions.UpdateApplicationOC,
+ ApprovalProgram: appr,
+ ClearStateProgram: []byte{2},
+ }
+ params = basics.AppParams{
+ ApprovalProgram: []byte{1},
+ StateSchemas: basics.StateSchemas{
+ GlobalStateSchema: basics.StateSchema{NumUint: 1},
+ },
+ ExtraProgramPages: 1,
+ }
+ h = transactions.Header{
+ Sender: sender,
+ }
+
+ b.balances = make(map[basics.Address]basics.AccountData)
+ cbr = basics.AccountData{
+ AppParams: map[basics.AppIndex]basics.AppParams{appIdx: params},
+ }
+ cp = basics.AccountData{
+ AppParams: map[basics.AppIndex]basics.AppParams{appIdx: params},
+ }
+ b.balances[creator] = cp
+ b.appCreators = map[basics.AppIndex]basics.Address{appIdx: creator}
+
+ //check program len check happens in future consensus proto version
+ b.SetProto(protocol.ConsensusFuture)
+ proto = b.ConsensusParams()
+ ep.Proto = &proto
+
+ b.pass = true
+ err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
+ a.Contains(err.Error(), "updateApplication app programs too long")
+
+ // check extraProgramPages is used
+ appr = make([]byte, 3072)
+
+ for i := range appr {
+ appr[i] = 2
+ }
+ appr[0] = 4
+ ac = transactions.ApplicationCallTxnFields{
+ ApplicationID: appIdx,
+ OnCompletion: transactions.UpdateApplicationOC,
+ ApprovalProgram: appr,
+ ClearStateProgram: []byte{2},
+ }
+ b.pass = true
+ err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
+ a.NoError(err)
+
}
func TestAppCallApplyDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -1008,7 +1092,6 @@ func TestAppCallApplyDelete(t *testing.T) {
a.Error(err)
a.Contains(err.Error(), "transaction rejected by ApprovalProgram")
a.Equal(0, b.put)
- a.Equal(0, b.putWith)
br := b.balances[creator]
a.Equal(cbr, br)
a.Equal(basics.EvalDelta{}, ad.EvalDelta)
@@ -1019,8 +1102,7 @@ func TestAppCallApplyDelete(t *testing.T) {
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(appIdx, b.deAllocatedAppIdx)
- a.Equal(0, b.put)
- a.Equal(1, b.putWith)
+ a.Equal(1, b.put)
br = b.balances[creator]
a.Equal(cbr, br)
br = b.putBalances[creator]
@@ -1031,6 +1113,8 @@ func TestAppCallApplyDelete(t *testing.T) {
}
func TestAppCallApplyCreateClearState(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
@@ -1079,6 +1163,8 @@ func TestAppCallApplyCreateClearState(t *testing.T) {
}
func TestAppCallApplyCreateDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
creator := getRandomAddress(a)
diff --git a/ledger/apply/apply.go b/ledger/apply/apply.go
index e7a01c6cf..739d7803c 100644
--- a/ledger/apply/apply.go
+++ b/ledger/apply/apply.go
@@ -33,21 +33,22 @@ type Balances interface {
Put(basics.Address, basics.AccountData) error
- // PutWithCreatable is like Put, but should be used when creating or deleting an asset or application.
- PutWithCreatable(addr basics.Address, acct basics.AccountData, newCreatable *basics.CreatableLocator, deletedCreatable *basics.CreatableLocator) error
-
// GetCreator gets the address of the account that created a given creatable
GetCreator(cidx basics.CreatableIndex, ctype basics.CreatableType) (basics.Address, bool, error)
- // Allocate or Deallocate either global or address-local app storage.
+ // Allocate or deallocate either global or address-local app storage.
//
- // PutWithCreatable(...) and then {Allocate/Deallocate}(..., ..., global=true)
+ // Put(...) and then {AllocateApp/DeallocateApp}(..., ..., global=true)
// creates/destroys an application.
//
- // Put(...) and then {Allocate/Deallocate}(..., ..., global=false)
+ // Put(...) and then {AllocateApp/DeallocateApp}(..., ..., global=false)
// opts into/closes out of an application.
- Allocate(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error
- Deallocate(addr basics.Address, aidx basics.AppIndex, global bool) error
+ AllocateApp(addr basics.Address, aidx basics.AppIndex, global bool, space basics.StateSchema) error
+ DeallocateApp(addr basics.Address, aidx basics.AppIndex, global bool) error
+
+ // Similar to above, notify COW that global/local asset state was created.
+ AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error
+ DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error
// StatefulEval executes a TEAL program in stateful mode on the balances.
// It returns whether the program passed and its error. It alo returns
diff --git a/ledger/apply/asset.go b/ledger/apply/asset.go
index 26d50acf2..4c74649b7 100644
--- a/ledger/apply/asset.go
+++ b/ledger/apply/asset.go
@@ -95,14 +95,13 @@ func AssetConfig(cc transactions.AssetConfigTxnFields, header transactions.Heade
return fmt.Errorf("too many assets in account: %d > %d", len(record.Assets), balances.ConsensusParams().MaxAssetsPerAccount)
}
- // Tell the cow what asset we created
- created := &basics.CreatableLocator{
- Creator: header.Sender,
- Type: basics.AssetCreatable,
- Index: basics.CreatableIndex(newidx),
+ err = balances.Put(header.Sender, record)
+ if err != nil {
+ return err
}
- return balances.PutWithCreatable(header.Sender, record, created, nil)
+ // Tell the cow what asset we created
+ return balances.AllocateAsset(header.Sender, newidx, true)
}
// Re-configuration and destroying must be done by the manager key.
@@ -123,7 +122,6 @@ func AssetConfig(cc transactions.AssetConfigTxnFields, header transactions.Heade
record.Assets = cloneAssetHoldings(record.Assets)
record.AssetParams = cloneAssetParams(record.AssetParams)
- var deleted *basics.CreatableLocator
if cc.AssetParams == (basics.AssetParams{}) {
// Destroying an asset. The creator account must hold
// the entire outstanding asset amount.
@@ -132,10 +130,9 @@ func AssetConfig(cc transactions.AssetConfigTxnFields, header transactions.Heade
}
// Tell the cow what asset we deleted
- deleted = &basics.CreatableLocator{
- Creator: creator,
- Type: basics.AssetCreatable,
- Index: basics.CreatableIndex(cc.ConfigAsset),
+ err = balances.DeallocateAsset(creator, cc.ConfigAsset, true)
+ if err != nil {
+ return err
}
delete(record.Assets, cc.ConfigAsset)
@@ -158,7 +155,7 @@ func AssetConfig(cc transactions.AssetConfigTxnFields, header transactions.Heade
record.AssetParams[cc.ConfigAsset] = params
}
- return balances.PutWithCreatable(creator, record, nil, deleted)
+ return balances.Put(creator, record)
}
func takeOut(balances Balances, addr basics.Address, asset basics.AssetIndex, amount uint64, bypassFreeze bool) error {
diff --git a/ledger/apply/asset_test.go b/ledger/apply/asset_test.go
index 4b1b58d1e..3fbad27c7 100644
--- a/ledger/apply/asset_test.go
+++ b/ledger/apply/asset_test.go
@@ -26,9 +26,12 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestAssetTransfer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Creator
secretSrc := keypair()
src := basics.Address(secretSrc.SignatureVerifier)
diff --git a/ledger/apply/keyreg_test.go b/ledger/apply/keyreg_test.go
index ce9185300..5a058b486 100644
--- a/ledger/apply/keyreg_test.go
+++ b/ledger/apply/keyreg_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -49,10 +50,6 @@ func (balances keyregTestBalances) Put(addr basics.Address, ad basics.AccountDat
return nil
}
-func (balances keyregTestBalances) PutWithCreatable(basics.Address, basics.AccountData, *basics.CreatableLocator, *basics.CreatableLocator) error {
- return nil
-}
-
func (balances keyregTestBalances) Move(src, dst basics.Address, amount basics.MicroAlgos, srcRewards, dstRewards *basics.MicroAlgos) error {
return nil
}
@@ -65,11 +62,19 @@ func (balances keyregTestBalances) Round() basics.Round {
return basics.Round(4294967296)
}
-func (balances keyregTestBalances) Allocate(basics.Address, basics.AppIndex, bool, basics.StateSchema) error {
+func (balances keyregTestBalances) AllocateApp(basics.Address, basics.AppIndex, bool, basics.StateSchema) error {
+ return nil
+}
+
+func (balances keyregTestBalances) DeallocateApp(basics.Address, basics.AppIndex, bool) error {
return nil
}
-func (balances keyregTestBalances) Deallocate(basics.Address, basics.AppIndex, bool) error {
+func (balances keyregTestBalances) AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ return nil
+}
+
+func (balances keyregTestBalances) DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
return nil
}
@@ -78,6 +83,8 @@ func (balances keyregTestBalances) StatefulEval(logic.EvalParams, basics.AppInde
}
func TestKeyregApply(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
secretSrc := keypair()
src := basics.Address(secretSrc.SignatureVerifier)
vrfSecrets := crypto.GenerateVRFSecrets()
diff --git a/ledger/apply/mockBalances_test.go b/ledger/apply/mockBalances_test.go
index fadc97fe1..a1b64a2f2 100644
--- a/ledger/apply/mockBalances_test.go
+++ b/ledger/apply/mockBalances_test.go
@@ -49,22 +49,26 @@ func (balances mockBalances) Round() basics.Round {
return basics.Round(8675309)
}
-func (balances mockBalances) Allocate(basics.Address, basics.AppIndex, bool, basics.StateSchema) error {
+func (balances mockBalances) AllocateApp(basics.Address, basics.AppIndex, bool, basics.StateSchema) error {
return nil
}
-func (balances mockBalances) Deallocate(basics.Address, basics.AppIndex, bool) error {
+func (balances mockBalances) DeallocateApp(basics.Address, basics.AppIndex, bool) error {
return nil
}
-func (balances mockBalances) StatefulEval(logic.EvalParams, basics.AppIndex, []byte) (bool, basics.EvalDelta, error) {
- return false, basics.EvalDelta{}, nil
+func (balances mockBalances) AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ return nil
}
-func (balances mockBalances) PutWithCreatable(basics.Address, basics.AccountData, *basics.CreatableLocator, *basics.CreatableLocator) error {
+func (balances mockBalances) DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
return nil
}
+func (balances mockBalances) StatefulEval(logic.EvalParams, basics.AppIndex, []byte) (bool, basics.EvalDelta, error) {
+ return false, basics.EvalDelta{}, nil
+}
+
func (balances mockBalances) Get(addr basics.Address, withPendingRewards bool) (basics.AccountData, error) {
return balances.b[addr], nil
}
diff --git a/ledger/apply/payment_test.go b/ledger/apply/payment_test.go
index 0e0c32473..09b55306d 100644
--- a/ledger/apply/payment_test.go
+++ b/ledger/apply/payment_test.go
@@ -27,6 +27,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var poolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
@@ -44,6 +45,8 @@ func keypair() *crypto.SignatureSecrets {
}
func TestAlgosEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var a basics.MicroAlgos
var b basics.MicroAlgos
var i uint64
@@ -77,6 +80,8 @@ func TestAlgosEncoding(t *testing.T) {
}
func TestPaymentApply(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
mockBalV0 := makeMockBalances(protocol.ConsensusCurrentVersion)
secretSrc := keypair()
@@ -104,6 +109,8 @@ func TestPaymentApply(t *testing.T) {
}
func TestCheckSpender(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
mockBalV0 := makeMockBalances(protocol.ConsensusCurrentVersion)
mockBalV7 := makeMockBalances(protocol.ConsensusV7)
@@ -143,6 +150,8 @@ func TestCheckSpender(t *testing.T) {
}
func TestPaymentValidation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
payments, _, _, _ := generateTestObjects(100, 50)
genHash := crypto.Digest{0x42}
for i, txn := range payments {
@@ -236,6 +245,8 @@ func TestPaymentValidation(t *testing.T) {
}
func TestPaymentSelfClose(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
secretSrc := keypair()
src := basics.Address(secretSrc.SignatureVerifier)
diff --git a/ledger/archival_test.go b/ledger/archival_test.go
index efd68c403..8ec3c6127 100644
--- a/ledger/archival_test.go
+++ b/ledger/archival_test.go
@@ -43,6 +43,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
@@ -112,6 +113,8 @@ func getInitState() (genesisInitState InitState) {
}
func TestArchival(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// This test ensures that trackers return the correct value from
// committedUpTo() -- that is, if they return round rnd, then they
// do not ask for any round before rnd on a subsequent call to
@@ -175,6 +178,8 @@ func TestArchival(t *testing.T) {
}
func TestArchivalRestart(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Start in archival mode, add 2K blocks, restart, ensure all blocks are there
// disable deadlock checking code
@@ -321,6 +326,8 @@ func makeUnsignedApplicationCallTx(appIdx uint64, onCompletion transactions.OnCo
}
func TestArchivalCreatables(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Start in archival mode, add 2K blocks with asset + app txns
// restart, ensure all assets are there in index unless they were
// deleted
@@ -677,6 +684,8 @@ func makeSignedTxnInBlock(tx transactions.Transaction) transactions.SignedTxnInB
}
func TestArchivalFromNonArchival(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Start in non-archival mode, add 2K blocks, restart in archival mode ensure only genesis block is there
deadlockDisable := deadlock.Opts.Disable
deadlock.Opts.Disable = true
diff --git a/ledger/assetcow.go b/ledger/assetcow.go
new file mode 100644
index 000000000..d84ae3221
--- /dev/null
+++ b/ledger/assetcow.go
@@ -0,0 +1,48 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package ledger
+
+import (
+ "github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/ledger/ledgercore"
+)
+
+func (cs *roundCowState) AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ if global {
+ cs.mods.Creatables[basics.CreatableIndex(index)] = ledgercore.ModifiedCreatable{
+ Ctype: basics.AssetCreatable,
+ Creator: addr,
+ Created: true,
+ }
+
+ cs.trackCreatable(basics.CreatableIndex(index))
+ }
+
+ return nil
+}
+
+func (cs *roundCowState) DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ if global {
+ cs.mods.Creatables[basics.CreatableIndex(index)] = ledgercore.ModifiedCreatable{
+ Ctype: basics.AssetCreatable,
+ Creator: addr,
+ Created: false,
+ }
+ }
+
+ return nil
+}
diff --git a/ledger/blockdb_test.go b/ledger/blockdb_test.go
index c7475edcc..0c2fa8ecd 100644
--- a/ledger/blockdb_test.go
+++ b/ledger/blockdb_test.go
@@ -30,6 +30,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
@@ -118,6 +119,8 @@ func setDbLogging(t testing.TB, dbs db.Pair) {
}
func TestBlockDBEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbs, _ := dbOpenTest(t, true)
setDbLogging(t, dbs)
defer dbs.Close()
@@ -132,6 +135,8 @@ func TestBlockDBEmpty(t *testing.T) {
}
func TestBlockDBInit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbs, _ := dbOpenTest(t, true)
setDbLogging(t, dbs)
defer dbs.Close()
@@ -152,6 +157,8 @@ func TestBlockDBInit(t *testing.T) {
}
func TestBlockDBAppend(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbs, _ := dbOpenTest(t, true)
setDbLogging(t, dbs)
defer dbs.Close()
diff --git a/ledger/blockqueue_test.go b/ledger/blockqueue_test.go
index 93bafc322..9b69d277d 100644
--- a/ledger/blockqueue_test.go
+++ b/ledger/blockqueue_test.go
@@ -30,9 +30,12 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestPutBlockTooOld(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
genesisInitState, _, _ := genesis(10)
dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64())
@@ -62,6 +65,8 @@ func TestPutBlockTooOld(t *testing.T) {
// TestGetEncodedBlockCert tests getEncodedBlockCert with valid and invalid round numbers.
func TestGetEncodedBlockCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
genesisInitState, _, _ := genesis(10)
const inMem = true
diff --git a/ledger/bulletin_test.go b/ledger/bulletin_test.go
index 3fb200ace..cf8d16043 100644
--- a/ledger/bulletin_test.go
+++ b/ledger/bulletin_test.go
@@ -17,6 +17,7 @@
package ledger
import (
+ "github.com/algorand/go-algorand/test/partitiontest"
"testing"
"time"
)
@@ -24,6 +25,8 @@ import (
const epsilon = 5 * time.Millisecond
func TestBulletin(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
bul := makeBulletin()
bul.committedUpTo(1)
diff --git a/ledger/catchpointwriter_test.go b/ledger/catchpointwriter_test.go
index 0892bc344..932ab37ad 100644
--- a/ledger/catchpointwriter_test.go
+++ b/ledger/catchpointwriter_test.go
@@ -35,6 +35,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func makeString(len int) string {
@@ -138,6 +139,8 @@ func makeTestEncodedBalanceRecord(t *testing.T) encodedBalanceRecord {
}
func TestEncodedBalanceRecordEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
er := makeTestEncodedBalanceRecord(t)
encodedBr := er.MarshalMsg(nil)
@@ -149,6 +152,8 @@ func TestEncodedBalanceRecordEncoding(t *testing.T) {
}
func TestCatchpointFileBalancesChunkEncoding(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
fbc := catchpointFileBalancesChunk{}
for i := 0; i < 512; i++ {
fbc.Balances = append(fbc.Balances, makeTestEncodedBalanceRecord(t))
@@ -163,6 +168,8 @@ func TestCatchpointFileBalancesChunkEncoding(t *testing.T) {
}
func TestBasicCatchpointWriter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// create new protocol version, which has lower lookback
testProtocolVersion := protocol.ConsensusVersion("test-protocol-TestBasicCatchpointWriter")
protoParams := config.Consensus[protocol.ConsensusCurrentVersion]
@@ -261,6 +268,8 @@ func TestBasicCatchpointWriter(t *testing.T) {
}
func TestFullCatchpointWriter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// create new protocol version, which has lower lookback
testProtocolVersion := protocol.ConsensusVersion("test-protocol-TestFullCatchpointWriter")
protoParams := config.Consensus[protocol.ConsensusCurrentVersion]
diff --git a/ledger/catchupaccessor_test.go b/ledger/catchupaccessor_test.go
index 6ecde269c..576280d8e 100644
--- a/ledger/catchupaccessor_test.go
+++ b/ledger/catchupaccessor_test.go
@@ -34,6 +34,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func createTestingEncodedChunks(accountsCount uint64) (encodedAccountChunks [][]byte, last64KIndex int) {
@@ -139,6 +140,8 @@ func BenchmarkRestoringFromCatchpointFile(b *testing.B) {
}
func TestCatchupAcessorFoo(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
dbBaseFileName := t.Name()
const inMem = true
@@ -192,6 +195,8 @@ func TestCatchupAcessorFoo(t *testing.T) {
}
func TestBuildMerkleTrie(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// setup boilerplate
log := logging.TestingLog(t)
dbBaseFileName := t.Name()
@@ -289,6 +294,8 @@ func TestBuildMerkleTrie(t *testing.T) {
// TODO: blockEnsureSingleBlock called from EnsureFirstBlock()
func TestCatchupAccessorBlockdb(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// setup boilerplate
log := logging.TestingLog(t)
dbBaseFileName := t.Name()
@@ -313,6 +320,8 @@ func TestCatchupAccessorBlockdb(t *testing.T) {
}
func TestVerifyCatchpoint(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// setup boilerplate
log := logging.TestingLog(t)
dbBaseFileName := t.Name()
diff --git a/ledger/compactcert_test.go b/ledger/compactcert_test.go
index 6c1c22ad4..27e466811 100644
--- a/ledger/compactcert_test.go
+++ b/ledger/compactcert_test.go
@@ -27,9 +27,12 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestValidateCompactCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var certHdr bookkeeping.BlockHeader
var cert compactcert.Cert
var votersHdr bookkeeping.BlockHeader
@@ -97,6 +100,8 @@ func TestValidateCompactCert(t *testing.T) {
}
func TestAcceptableCompactCertWeight(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var votersHdr bookkeeping.BlockHeader
var firstValid basics.Round
logger := logging.TestingLog(t)
@@ -141,6 +146,8 @@ func TestAcceptableCompactCertWeight(t *testing.T) {
}
func TestCompactCertParams(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var votersHdr bookkeeping.BlockHeader
var hdr bookkeeping.BlockHeader
diff --git a/ledger/cow.go b/ledger/cow.go
index ba17dafc5..56ff9e33b 100644
--- a/ledger/cow.go
+++ b/ledger/cow.go
@@ -194,26 +194,6 @@ func (cb *roundCowState) blockHdr(r basics.Round) (bookkeeping.BlockHeader, erro
return cb.lookupParent.blockHdr(r)
}
-func (cb *roundCowState) put(addr basics.Address, new basics.AccountData, newCreatable *basics.CreatableLocator, deletedCreatable *basics.CreatableLocator) {
- cb.mods.Accts.Upsert(addr, new)
-
- if newCreatable != nil {
- cb.mods.Creatables[newCreatable.Index] = ledgercore.ModifiedCreatable{
- Ctype: newCreatable.Type,
- Creator: newCreatable.Creator,
- Created: true,
- }
- }
-
- if deletedCreatable != nil {
- cb.mods.Creatables[deletedCreatable.Index] = ledgercore.ModifiedCreatable{
- Ctype: deletedCreatable.Type,
- Creator: deletedCreatable.Creator,
- Created: false,
- }
- }
-}
-
func (cb *roundCowState) trackCreatable(creatableIndex basics.CreatableIndex) {
cb.trackedCreatables[cb.groupIdx] = creatableIndex
}
diff --git a/ledger/cow_test.go b/ledger/cow_test.go
index b09c479e8..273ab3faa 100644
--- a/ledger/cow_test.go
+++ b/ledger/cow_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/ledgercore"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type mockLedger struct {
@@ -101,11 +102,13 @@ func checkCow(t *testing.T, cow *roundCowState, accts map[basics.Address]basics.
func applyUpdates(cow *roundCowState, updates ledgercore.AccountDeltas) {
for i := 0; i < updates.Len(); i++ {
addr, delta := updates.GetByIdx(i)
- cow.put(addr, delta, nil, nil)
+ cow.Put(addr, delta)
}
}
func TestCowBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
accts0 := randomAccounts(20, true)
ml := mockLedger{balanceMap: accts0}
diff --git a/ledger/eval.go b/ledger/eval.go
index 3b1968a74..54cdeedd7 100644
--- a/ledger/eval.go
+++ b/ledger/eval.go
@@ -247,16 +247,7 @@ func (cs *roundCowState) GetCreator(cidx basics.CreatableIndex, ctype basics.Cre
}
func (cs *roundCowState) Put(addr basics.Address, acct basics.AccountData) error {
- return cs.PutWithCreatable(addr, acct, nil, nil)
-}
-
-func (cs *roundCowState) PutWithCreatable(addr basics.Address, acct basics.AccountData, newCreatable *basics.CreatableLocator, deletedCreatable *basics.CreatableLocator) error {
- cs.put(addr, acct, newCreatable, deletedCreatable)
-
- // store the creatable locator
- if newCreatable != nil {
- cs.trackCreatable(newCreatable.Index)
- }
+ cs.mods.Accts.Upsert(addr, acct)
return nil
}
@@ -283,7 +274,7 @@ func (cs *roundCowState) Move(from basics.Address, to basics.Address, amt basics
if overflowed {
return fmt.Errorf("overspend (account %v, data %+v, tried to spend %v)", from, fromBal, amt)
}
- cs.put(from, fromBalNew, nil, nil)
+ cs.Put(from, fromBalNew)
toBal, err := cs.lookup(to)
if err != nil {
@@ -304,7 +295,7 @@ func (cs *roundCowState) Move(from basics.Address, to basics.Address, amt basics
if overflowed {
return fmt.Errorf("balance overflow (account %v, data %+v, was going to receive %v)", to, toBal, amt)
}
- cs.put(to, toBalNew, nil, nil)
+ cs.Put(to, toBalNew)
return nil
}
@@ -383,15 +374,15 @@ type ledgerForCowBase interface {
// payset being evaluated is known in advance, a paysetHint >= 0 can be
// passed, avoiding unnecessary payset slice growth.
func (l *Ledger) StartEvaluator(hdr bookkeeping.BlockHeader, paysetHint int) (*BlockEvaluator, error) {
- return startEvaluator(l, hdr, paysetHint, true, true)
-}
-
-func startEvaluator(l ledgerForEvaluator, hdr bookkeeping.BlockHeader, paysetHint int, validate bool, generate bool) (*BlockEvaluator, error) {
proto, ok := config.Consensus[hdr.CurrentProtocol]
if !ok {
return nil, protocol.Error(hdr.CurrentProtocol)
}
+ return startEvaluator(l, hdr, proto, paysetHint, true, true)
+}
+
+func startEvaluator(l ledgerForEvaluator, hdr bookkeeping.BlockHeader, proto config.ConsensusParams, paysetHint int, validate bool, generate bool) (*BlockEvaluator, error) {
base := &roundCowBase{
l: l,
// round that lookups come from is previous block. We validate
@@ -432,6 +423,8 @@ func startEvaluator(l ledgerForEvaluator, hdr bookkeeping.BlockHeader, paysetHin
base.txnCount = eval.prevHeader.TxnCounter
base.compactCertNextRnd = eval.prevHeader.CompactCert[protocol.CompactCertBasic].CompactCertNextRound
+
+ var ok bool
prevProto, ok = config.Consensus[eval.prevHeader.CurrentProtocol]
if !ok {
return nil, protocol.Error(eval.prevHeader.CurrentProtocol)
@@ -1166,7 +1159,13 @@ func (validator *evalTxValidator) run() {
// AddBlock: eval(context.Background(), l, blk, false, txcache, nil, true)
// tracker: eval(context.Background(), l, blk, false, txcache, nil, false)
func eval(ctx context.Context, l ledgerForEvaluator, blk bookkeeping.Block, validate bool, txcache verify.VerifiedTransactionCache, executionPool execpool.BacklogPool) (ledgercore.StateDelta, error) {
- eval, err := startEvaluator(l, blk.BlockHeader, len(blk.Payset), validate, false)
+ proto, ok := config.Consensus[blk.BlockHeader.CurrentProtocol]
+ if !ok {
+ return ledgercore.StateDelta{}, protocol.Error(blk.BlockHeader.CurrentProtocol)
+ }
+
+ eval, err := startEvaluator(
+ l, blk.BlockHeader, proto, len(blk.Payset), validate, false)
if err != nil {
return ledgercore.StateDelta{}, err
}
@@ -1240,7 +1239,7 @@ transactionGroupLoop:
}
}
- // Finally, proceeds any pending end-of-block state changes
+ // Finally, process any pending end-of-block state changes.
err = eval.endOfBlock()
if err != nil {
return ledgercore.StateDelta{}, err
@@ -1488,3 +1487,36 @@ func (vb ValidatedBlock) WithSeed(s committee.Seed) ValidatedBlock {
delta: vb.delta,
}
}
+
+// Eval evaluates a block without validation using the given `proto`. Return the state
+// delta and transactions with modified apply data according to `proto`.
+// This function is used by Indexer which modifies `proto` to retrieve the asset
+// close amount for each transaction even when the real consensus parameters do not
+// support it.
+func Eval(l ledgerForEvaluator, blk *bookkeeping.Block, proto config.ConsensusParams) (ledgercore.StateDelta, []transactions.SignedTxnInBlock, error) {
+ eval, err := startEvaluator(
+ l, blk.BlockHeader, proto, len(blk.Payset), false, false)
+ if err != nil {
+ return ledgercore.StateDelta{}, []transactions.SignedTxnInBlock{}, err
+ }
+
+ paysetgroups, err := blk.DecodePaysetGroups()
+ if err != nil {
+ return ledgercore.StateDelta{}, []transactions.SignedTxnInBlock{}, err
+ }
+
+ for _, group := range paysetgroups {
+ err = eval.TransactionGroup(group)
+ if err != nil {
+ return ledgercore.StateDelta{}, []transactions.SignedTxnInBlock{}, err
+ }
+ }
+
+ // Finally, process any pending end-of-block state changes.
+ err = eval.endOfBlock()
+ if err != nil {
+ return ledgercore.StateDelta{}, []transactions.SignedTxnInBlock{}, err
+ }
+
+ return eval.state.deltas(), eval.block.Payset, nil
+}
diff --git a/ledger/eval_test.go b/ledger/eval_test.go
index 2ea3a3939..9d3315a1b 100644
--- a/ledger/eval_test.go
+++ b/ledger/eval_test.go
@@ -39,6 +39,7 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/execpool"
)
@@ -52,6 +53,8 @@ func init() {
}
func TestBlockEvaluator(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
genesisInitState, addrs, keys := genesis(10)
dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64())
@@ -222,6 +225,8 @@ func TestBlockEvaluator(t *testing.T) {
}
func TestRekeying(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Pretend rekeying is supported
actual := config.Consensus[protocol.ConsensusCurrentVersion]
pretend := actual
@@ -327,6 +332,8 @@ func TestRekeying(t *testing.T) {
}
func TestPrepareEvalParams(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
eval := BlockEvaluator{
prevHeader: bookkeeping.BlockHeader{
TimeStamp: 1234,
@@ -532,6 +539,8 @@ ok:
// commitToParent -> applyChild copies child's cow state usage counts into parent
// and the usage counts correctly propagated from parent cow to child cow and back
func TestEvalAppStateCountsWithTxnGroup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
_, _, err := testEvalAppGroup(t, basics.StateSchema{NumByteSlice: 1})
require.Error(t, err)
require.Contains(t, err.Error(), "store bytes count 2 exceeds schema bytes count 1")
@@ -540,6 +549,8 @@ func TestEvalAppStateCountsWithTxnGroup(t *testing.T) {
// TestEvalAppAllocStateWithTxnGroup ensures roundCowState.deltas and applyStorageDelta
// produce correct results when a txn group has storage allocate and storage update actions
func TestEvalAppAllocStateWithTxnGroup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
eval, addr, err := testEvalAppGroup(t, basics.StateSchema{NumByteSlice: 2})
require.NoError(t, err)
deltas := eval.state.deltas()
@@ -677,6 +688,8 @@ func benchmarkBlockEvaluator(b *testing.B, inMem bool, withCrypto bool) {
}
func TestCowCompactCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var certRnd basics.Round
var certType protocol.CompactCertType
var cert compactcert.Cert
@@ -735,6 +748,8 @@ func TestCowCompactCert(t *testing.T) {
// a couple trivial tests that don't need setup
// see TestBlockEvaluator for more
func TestTestTransactionGroup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var txgroup []transactions.SignedTxn
eval := BlockEvaluator{}
err := eval.TestTransactionGroup(txgroup)
@@ -749,6 +764,8 @@ func TestTestTransactionGroup(t *testing.T) {
// test BlockEvaluator.transactionGroup()
// some trivial checks that require no setup
func TestPrivateTransactionGroup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var txgroup []transactions.SignedTxnWithAD
eval := BlockEvaluator{}
err := eval.transactionGroup(txgroup)
@@ -763,6 +780,8 @@ func TestPrivateTransactionGroup(t *testing.T) {
// BlockEvaluator.workaroundOverspentRewards() fixed a couple issues on testnet.
// This is now part of history and has to be re-created when running catchup on testnet. So, test to ensure it keeps happenning.
func TestTestnetFixup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
eval := &BlockEvaluator{}
var rewardPoolBalance basics.AccountData
rewardPoolBalance.MicroAlgos.Raw = 1234
diff --git a/ledger/ledger_test.go b/ledger/ledger_test.go
index 0e2249456..432e11848 100644
--- a/ledger/ledger_test.go
+++ b/ledger/ledger_test.go
@@ -38,6 +38,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/execpool"
)
@@ -254,6 +255,8 @@ func (l *Ledger) addBlockTxns(t *testing.T, accounts map[basics.Address]basics.A
}
func TestLedgerBasic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
genesisInitState, _ := testGenerateInitState(t, protocol.ConsensusCurrentVersion, 100)
const inMem = true
cfg := config.GetDefaultLocal()
@@ -265,6 +268,8 @@ func TestLedgerBasic(t *testing.T) {
}
func TestLedgerBlockHeaders(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
genesisInitState, _ := testGenerateInitState(t, protocol.ConsensusCurrentVersion, 100)
@@ -406,6 +411,8 @@ func TestLedgerBlockHeaders(t *testing.T) {
}
func TestLedgerSingleTx(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
// V15 is the earliest protocol version in active use.
@@ -609,6 +616,8 @@ func TestLedgerSingleTx(t *testing.T) {
}
func TestLedgerSingleTxV24(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
protoName := protocol.ConsensusV24
@@ -778,6 +787,8 @@ func addEmptyValidatedBlock(t *testing.T, l *Ledger, initAccounts map[basics.Add
// TestLedgerAppCrossRoundWrites ensures app state writes survive between rounds
func TestLedgerAppCrossRoundWrites(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
protoName := protocol.ConsensusV24
@@ -914,6 +925,8 @@ int 1
// TestLedgerAppMultiTxnWrites ensures app state writes in multiple txn are applied
func TestLedgerAppMultiTxnWrites(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
protoName := protocol.ConsensusV24
@@ -1309,31 +1322,45 @@ func testLedgerSingleTxApplyData(t *testing.T, version protocol.ConsensusVersion
}
func TestLedgerSingleTxApplyData(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerSingleTxApplyData(t, protocol.ConsensusCurrentVersion)
}
// SupportTransactionLeases was introduced after v18.
func TestLedgerSingleTxApplyDataV18(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerSingleTxApplyData(t, protocol.ConsensusV18)
}
func TestLedgerSingleTxApplyDataFuture(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerSingleTxApplyData(t, protocol.ConsensusFuture)
}
func TestLedgerRegressionFaultyLeaseFirstValidCheckOld(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerRegressionFaultyLeaseFirstValidCheck2f3880f7(t, protocol.ConsensusV22)
}
func TestLedgerRegressionFaultyLeaseFirstValidCheckV23(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerRegressionFaultyLeaseFirstValidCheck2f3880f7(t, protocol.ConsensusV23)
}
func TestLedgerRegressionFaultyLeaseFirstValidCheck(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerRegressionFaultyLeaseFirstValidCheck2f3880f7(t, protocol.ConsensusCurrentVersion)
}
func TestLedgerRegressionFaultyLeaseFirstValidCheckFuture(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testLedgerRegressionFaultyLeaseFirstValidCheck2f3880f7(t, protocol.ConsensusFuture)
}
@@ -1400,6 +1427,8 @@ func testLedgerRegressionFaultyLeaseFirstValidCheck2f3880f7(t *testing.T, versio
}
func TestLedgerBlockHdrCaching(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64())
genesisInitState := getInitState()
const inMem = true
@@ -1425,6 +1454,8 @@ func TestLedgerBlockHdrCaching(t *testing.T) {
}
func TestLedgerReload(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64())
genesisInitState := getInitState()
const inMem = true
@@ -1459,6 +1490,7 @@ func TestLedgerReload(t *testing.T) {
// TestGetLastCatchpointLabel tests ledger.GetLastCatchpointLabel is returning the correct value.
func TestGetLastCatchpointLabel(t *testing.T) {
+ partitiontest.PartitionTest(t)
//initLedger
genesisInitState, _ := testGenerateInitState(t, protocol.ConsensusCurrentVersion, 100)
@@ -1535,6 +1567,7 @@ func generateCreatables(numElementsPerSegement int) (
// interfaces. The detailed test on the correctness of these functions is given in:
// TestListCreatables (acctupdates_test.go)
func TestListAssetsAndApplications(t *testing.T) {
+ partitiontest.PartitionTest(t)
numElementsPerSegement := 10 // This is multiplied by 10. see randomCreatables
@@ -1594,6 +1627,8 @@ func TestListAssetsAndApplications(t *testing.T) {
}
func TestLedgerMemoryLeak(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip() // for manual runs only
dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64())
genesisInitState, initKeys := testGenerateInitState(t, protocol.ConsensusCurrentVersion, 10000000000)
diff --git a/ledger/ledgercore/catchpointlabel_test.go b/ledger/ledgercore/catchpointlabel_test.go
index fe72f2ef7..cfe744baa 100644
--- a/ledger/ledgercore/catchpointlabel_test.go
+++ b/ledger/ledgercore/catchpointlabel_test.go
@@ -23,9 +23,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestUniqueCatchpointLabel(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
uniqueSet := make(map[string]bool)
ledgerRoundBlockHashes := []crypto.Digest{}
@@ -55,6 +58,8 @@ func TestUniqueCatchpointLabel(t *testing.T) {
}
func TestCatchpointLabelParsing(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledgerRoundBlockHashes := []crypto.Digest{}
balancesMerkleRoots := []crypto.Digest{}
totals := []AccountTotals{}
@@ -83,6 +88,8 @@ func TestCatchpointLabelParsing(t *testing.T) {
}
}
func TestCatchpointLabelParsing2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
_, _, err := ParseCatchpointLabel("5893060#KURJLS6EWBEVXTMLC7NP3NABTUMQP32QUJOBBW2TT23376L6RWJAB")
require.Error(t, err)
_, _, err = ParseCatchpointLabel("5893060KURJLS6EWBEVXTMLC7NP3NABTUMQP32QUJOBBW2TT23376L6RWJA")
diff --git a/ledger/ledgercore/msgp_gen_test.go b/ledger/ledgercore/msgp_gen_test.go
index 3837c8a21..99ad64e4d 100644
--- a/ledger/ledgercore/msgp_gen_test.go
+++ b/ledger/ledgercore/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalAccountTotals(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AccountTotals{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalAccountTotals(b *testing.B) {
}
func TestMarshalUnmarshalAlgoCount(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := AlgoCount{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/ledger/ledgercore/statedelta.go b/ledger/ledgercore/statedelta.go
index f2d2e3feb..80d6ad7fe 100644
--- a/ledger/ledgercore/statedelta.go
+++ b/ledger/ledgercore/statedelta.go
@@ -84,7 +84,8 @@ type StateDelta struct {
// AccountDeltas stores ordered accounts and allows fast lookup by address
type AccountDeltas struct {
- // actual data
+ // Actual data. If an account is deleted, `accts` contains a balance record
+ // with empty `AccountData`.
accts []basics.BalanceRecord
// cache for addr to deltas index resolution
acctsCache map[basics.Address]int
diff --git a/ledger/ledgercore/statedelta_test.go b/ledger/ledgercore/statedelta_test.go
index 8f3b81d91..f2f8bf7ad 100644
--- a/ledger/ledgercore/statedelta_test.go
+++ b/ledger/ledgercore/statedelta_test.go
@@ -23,6 +23,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func randomAddress() basics.Address {
@@ -32,6 +33,8 @@ func randomAddress() basics.Address {
}
func TestAccountDeltas(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
ad := AccountDeltas{}
diff --git a/ledger/ledgercore/totals_test.go b/ledger/ledgercore/totals_test.go
index ebb2c9b34..cabbd45e4 100644
--- a/ledger/ledgercore/totals_test.go
+++ b/ledger/ledgercore/totals_test.go
@@ -23,9 +23,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestAccountTotalsCanMarshalMsg(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var at *AccountTotals
require.True(t, at.CanMarshalMsg(interface{}(at)))
require.False(t, at.CanMarshalMsg(interface{}(t)))
@@ -33,6 +36,8 @@ func TestAccountTotalsCanMarshalMsg(t *testing.T) {
require.False(t, at.CanUnmarshalMsg(interface{}(t)))
}
func TestAccountTotalsMarshalMsg(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
at := AccountTotals{
Online: AlgoCount{
Money: basics.MicroAlgos{Raw: 0x1234123412340001},
@@ -59,6 +64,8 @@ func TestAccountTotalsMarshalMsg(t *testing.T) {
}
func TestAlgoCountMarshalMsg(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ac := AlgoCount{
Money: basics.MicroAlgos{Raw: 0x4321432143214321},
RewardUnits: 0x1234123412341234,
@@ -197,6 +204,8 @@ var uniqueAccountTotals = []AccountTotals{
}
func TestAccountTotalsMarshalMsgUnique(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
uniqueAt := make(map[crypto.Digest]bool, 0)
for _, at := range uniqueAccountTotals {
inBuffer := make([]byte, 0, 128)
@@ -208,6 +217,8 @@ func TestAccountTotalsMarshalMsgUnique(t *testing.T) {
}
func TestAccountTotalsMarshalUnMarshal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for _, at := range uniqueAccountTotals {
inBuffer := make([]byte, 0, 128)
outBuffer := at.MarshalMsg(inBuffer)
diff --git a/ledger/lruaccts_test.go b/ledger/lruaccts_test.go
index 4080cd3a3..4c4d12ca3 100644
--- a/ledger/lruaccts_test.go
+++ b/ledger/lruaccts_test.go
@@ -26,9 +26,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestBasicLRUAccounts(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var baseAcct lruAccounts
baseAcct.init(logging.TestingLog(t), 10, 5)
@@ -85,6 +88,8 @@ func TestBasicLRUAccounts(t *testing.T) {
}
func TestLRUAccountsPendingWrites(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var baseAcct lruAccounts
accountsNum := 250
baseAcct.init(logging.TestingLog(t), accountsNum*2, accountsNum)
@@ -135,6 +140,8 @@ func (cl *lruAccountsTestLogger) Warnf(s string, args ...interface{}) {
}
func TestLRUAccountsPendingWritesWarning(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var baseAcct lruAccounts
pendingWritesBuffer := 50
pendingWritesThreshold := 40
@@ -159,6 +166,8 @@ func TestLRUAccountsPendingWritesWarning(t *testing.T) {
}
func TestLRUAccountsOmittedPendingWrites(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var baseAcct lruAccounts
pendingWritesBuffer := 50
pendingWritesThreshold := 40
diff --git a/ledger/msgp_gen_test.go b/ledger/msgp_gen_test.go
index 5983f1d9a..af4deb819 100644
--- a/ledger/msgp_gen_test.go
+++ b/ledger/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalCatchpointFileHeader(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := CatchpointFileHeader{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalCatchpointFileHeader(b *testing.B) {
}
func TestMarshalUnmarshalcatchpointFileBalancesChunk(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := catchpointFileBalancesChunk{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -130,6 +133,7 @@ func BenchmarkUnmarshalcatchpointFileBalancesChunk(b *testing.B) {
}
func TestMarshalUnmarshalencodedBalanceRecord(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := encodedBalanceRecord{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/ledger/onlineacct_test.go b/ledger/onlineacct_test.go
index cd7eb4230..c1d05fa15 100644
--- a/ledger/onlineacct_test.go
+++ b/ledger/onlineacct_test.go
@@ -23,9 +23,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestOnlineTopHeap_Less(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := onlineTopHeap{
accts: []*onlineAccount{
{
@@ -53,6 +56,8 @@ func TestOnlineTopHeap_Less(t *testing.T) {
}
func TestOnlineTopHeap_Swap(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := onlineTopHeap{
accts: []*onlineAccount{
{
@@ -80,6 +85,8 @@ func TestOnlineTopHeap_Swap(t *testing.T) {
}
func TestOnlineTopHeap_Push(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := onlineTopHeap{
accts: []*onlineAccount{
{
@@ -109,6 +116,8 @@ func TestOnlineTopHeap_Push(t *testing.T) {
}
func TestOnlineTopHeap_Pop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
h := onlineTopHeap{
accts: []*onlineAccount{
{
diff --git a/ledger/roundlru_test.go b/ledger/roundlru_test.go
index 6d2c4317b..7837bd555 100644
--- a/ledger/roundlru_test.go
+++ b/ledger/roundlru_test.go
@@ -22,6 +22,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func getEq(t *testing.T, cache *heapLRUCache, r basics.Round, expected string) {
@@ -45,6 +46,8 @@ func getNone(t *testing.T, cache *heapLRUCache, r basics.Round) {
}
func TestRoundLRUBasic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
cache := heapLRUCache{maxEntries: 3}
cache.Put(1, "one")
cache.Put(2, "two")
@@ -63,6 +66,8 @@ func TestRoundLRUBasic(t *testing.T) {
}
func TestRoundLRUReIndex(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
cache := heapLRUCache{
entries: lruHeap{
heap: []lruEntry{
diff --git a/ledger/txtail_test.go b/ledger/txtail_test.go
index cefebedae..97d5a5cbb 100644
--- a/ledger/txtail_test.go
+++ b/ledger/txtail_test.go
@@ -29,9 +29,12 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestTxTailCheckdup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
ledger := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusCurrentVersion)
proto := config.Consensus[protocol.ConsensusCurrentVersion]
tail := txTail{}
diff --git a/logging/log.go b/logging/log.go
index 6877c6655..2af5e9f63 100644
--- a/logging/log.go
+++ b/logging/log.go
@@ -320,6 +320,10 @@ func (l logger) source() *logrus.Entry {
if !ok {
file = "<???>"
line = 1
+ event = event.WithFields(logrus.Fields{
+ "file": file,
+ "line": line,
+ })
} else {
// Add file name and number
slash := strings.LastIndex(file, "/")
diff --git a/logging/telemetry.go b/logging/telemetry.go
index e231a51e9..f5bafc4bb 100644
--- a/logging/telemetry.go
+++ b/logging/telemetry.go
@@ -24,7 +24,7 @@ import (
"strings"
"time"
- "github.com/satori/go.uuid"
+ uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
"github.com/algorand/go-algorand/config"
@@ -186,7 +186,6 @@ func EnsureTelemetryConfigCreated(dataDir *string, genesisID string) (TelemetryC
}
created := false
if err != nil {
- err = nil
created = true
cfg = createTelemetryConfig()
diff --git a/netdeploy/networkTemplates_test.go b/netdeploy/networkTemplates_test.go
index 4281cfad2..cc31f73aa 100644
--- a/netdeploy/networkTemplates_test.go
+++ b/netdeploy/networkTemplates_test.go
@@ -25,9 +25,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/config"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestLoadConfig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
templateDir, err := filepath.Abs("../test/testdata/nettemplates")
@@ -39,6 +42,8 @@ func TestLoadConfig(t *testing.T) {
}
func TestLoadMissingConfig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
templateDir, err := filepath.Abs("../test/testdata/nettemplates")
@@ -48,6 +53,8 @@ func TestLoadMissingConfig(t *testing.T) {
}
func TestGenerateGenesis(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
templateDir, _ := filepath.Abs("../test/testdata/nettemplates")
@@ -66,6 +73,8 @@ func TestGenerateGenesis(t *testing.T) {
}
func TestValidate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
templateDir, _ := filepath.Abs("../test/testdata/nettemplates")
diff --git a/netdeploy/network_test.go b/netdeploy/network_test.go
index 0ab24ed19..958930fac 100644
--- a/netdeploy/network_test.go
+++ b/netdeploy/network_test.go
@@ -25,9 +25,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/config"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestSaveNetworkCfg(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
cfg := NetworkCfg{
@@ -46,6 +49,8 @@ func TestSaveNetworkCfg(t *testing.T) {
}
func TestSaveConsensus(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
tmpFolder, _ := ioutil.TempDir("", "tmp")
diff --git a/netdeploy/remote/bootstrappedNetwork_test.go b/netdeploy/remote/bootstrappedNetwork_test.go
index e863912db..ba1722d94 100644
--- a/netdeploy/remote/bootstrappedNetwork_test.go
+++ b/netdeploy/remote/bootstrappedNetwork_test.go
@@ -20,10 +20,13 @@ import (
"path/filepath"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestLoadBootstrappedData(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
badSpecPath := filepath.Join("./../../test", "testdata/deployednettemplates/networks/bootstrapped/badSpec.json")
_, err := LoadBootstrappedData(badSpecPath)
require.NotEqual(t, nil, err)
diff --git a/netdeploy/remote/deployedNetwork_test.go b/netdeploy/remote/deployedNetwork_test.go
index 923726219..299424943 100644
--- a/netdeploy/remote/deployedNetwork_test.go
+++ b/netdeploy/remote/deployedNetwork_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestCreateSignedTx(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var networkState netState
networkState.nApplications = 2
networkState.nAssets = 2
@@ -112,6 +115,8 @@ func TestCreateSignedTx(t *testing.T) {
}
func TestAccountsNeeded(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
params := config.Consensus[protocol.ConsensusCurrentVersion]
params.MaxAppsCreated = 10
params.MaxAssetsPerAccount = 20
diff --git a/network/connPerfMon_test.go b/network/connPerfMon_test.go
index a78f73693..401b7d3ba 100644
--- a/network/connPerfMon_test.go
+++ b/network/connPerfMon_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func makeMsgPool(N int, peers []Peer) (out []IncomingMessage) {
@@ -92,6 +93,8 @@ func BenchmarkConnMonitor(b *testing.B) {
}
func TestConnMonitorStageTiming(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
peers := []Peer{&wsPeer{}, &wsPeer{}, &wsPeer{}, &wsPeer{}}
msgPool := makeMsgPool(60000, peers)
@@ -128,6 +131,8 @@ func TestConnMonitorStageTiming(t *testing.T) {
}
func TestBucketsPruning(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
bucketsCount := 100
curTime := time.Now().UnixNano()
for i := 0; i < bucketsCount; i++ {
diff --git a/network/limited_reader_slurper_test.go b/network/limited_reader_slurper_test.go
index d48896196..e13fcacce 100644
--- a/network/limited_reader_slurper_test.go
+++ b/network/limited_reader_slurper_test.go
@@ -25,9 +25,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestLimitedReaderSlurper(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for _, arraySize := range []uint64{30000, 90000, 200000} {
// create a random bytes array.
bytesBlob := make([]byte, arraySize)
@@ -76,6 +79,8 @@ func (f *fuzzReader) Read(b []byte) (n int, err error) {
}
func TestLimitedReaderSlurper_FuzzedBlippedSource(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
arraySize := uint64(300000)
bytesBlob := make([]byte, arraySize)
crypto.RandBytes(bytesBlob[:])
@@ -121,6 +126,8 @@ func BenchmarkLimitedReaderSlurper(b *testing.B) {
}
func TestLimitedReaderSlurperMemoryConsumption(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for _, arraySize := range []uint64{1024, 2048, 65536, 1024 * 1024} {
result := testing.Benchmark(func(b *testing.B) {
benchmarkLimitedReaderSlurper(b, arraySize)
@@ -130,6 +137,8 @@ func TestLimitedReaderSlurperMemoryConsumption(t *testing.T) {
}
func TestLimitedReaderSlurperBufferAllocations(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for baseAllocation := uint64(512); baseAllocation < 100000; baseAllocation += 2048 {
for maxAllocation := uint64(512); maxAllocation < 100000; maxAllocation += 512 {
lrs := MakeLimitedReaderSlurper(baseAllocation, maxAllocation)
diff --git a/network/msgOfInterest_test.go b/network/msgOfInterest_test.go
index d74618efb..ba3fe798b 100644
--- a/network/msgOfInterest_test.go
+++ b/network/msgOfInterest_test.go
@@ -22,9 +22,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestUnmarshallMessageOfInterestErrors(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
tags, err := unmarshallMessageOfInterest([]byte{0x88})
require.Equal(t, errUnableUnmarshallMessage, err)
require.Equal(t, 0, len(tags))
@@ -46,6 +49,8 @@ func TestUnmarshallMessageOfInterestErrors(t *testing.T) {
}
func TestMarshallMessageOfInterest(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
bytes := MarshallMessageOfInterest([]protocol.Tag{protocol.AgreementVoteTag})
tags, err := unmarshallMessageOfInterest(bytes)
require.NoError(t, err)
diff --git a/network/multiplexer_test.go b/network/multiplexer_test.go
index 67830d7ea..cd5bca0c2 100644
--- a/network/multiplexer_test.go
+++ b/network/multiplexer_test.go
@@ -24,6 +24,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func makeSignedTxnMsg() IncomingMessage {
@@ -54,6 +55,8 @@ func (th *testHandler) SawMsg(msg IncomingMessage) bool {
}
func TestMultiplexer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
m := MakeMultiplexer(logging.TestingLog(t))
handler := &testHandler{}
diff --git a/network/phonebook_test.go b/network/phonebook_test.go
index e30a221c8..bd8e712bf 100644
--- a/network/phonebook_test.go
+++ b/network/phonebook_test.go
@@ -23,6 +23,7 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -86,6 +87,8 @@ func testPhonebookUniform(t *testing.T, set []string, ph Phonebook, getsize int)
}
func TestArrayPhonebookAll(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
set := []string{"a", "b", "c", "d", "e"}
ph := MakePhonebook(1, 1).(*phonebookImpl)
for _, e := range set {
@@ -95,6 +98,8 @@ func TestArrayPhonebookAll(t *testing.T) {
}
func TestArrayPhonebookUniform1(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
set := []string{"a", "b", "c", "d", "e"}
ph := MakePhonebook(1, 1).(*phonebookImpl)
for _, e := range set {
@@ -104,6 +109,8 @@ func TestArrayPhonebookUniform1(t *testing.T) {
}
func TestArrayPhonebookUniform3(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
set := []string{"a", "b", "c", "d", "e"}
ph := MakePhonebook(1, 1).(*phonebookImpl)
for _, e := range set {
@@ -115,6 +122,8 @@ func TestArrayPhonebookUniform3(t *testing.T) {
// TestPhonebookExtension tests for extending different phonebooks with
// addresses.
func TestPhonebookExtension(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
setA := []string{"a"}
moreB := []string{"b"}
ph := MakePhonebook(1, 1).(*phonebookImpl)
@@ -139,6 +148,8 @@ func extenderThread(th *phonebookImpl, more []string, wg *sync.WaitGroup, repeti
}
func TestThreadsafePhonebookExtension(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
set := []string{"a", "b", "c", "d", "e"}
more := []string{"f", "g", "h", "i", "j"}
ph := MakePhonebook(1, 1).(*phonebookImpl)
@@ -163,6 +174,8 @@ func threadTestThreadsafePhonebookExtensionLong(wg *sync.WaitGroup, ph *phoneboo
}
func TestThreadsafePhonebookExtensionLong(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.SkipNow()
return
@@ -183,6 +196,8 @@ func TestThreadsafePhonebookExtensionLong(t *testing.T) {
}
func TestMultiPhonebook(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
set := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
pha := make([]string, 0)
for _, e := range set[:5] {
@@ -202,6 +217,8 @@ func TestMultiPhonebook(t *testing.T) {
}
func TestMultiPhonebookDuplicateFiltering(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
set := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
pha := make([]string, 0)
for _, e := range set[:7] {
@@ -221,6 +238,8 @@ func TestMultiPhonebookDuplicateFiltering(t *testing.T) {
}
func TestWaitAndAddConnectionTimeLongtWindow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
entries := MakePhonebook(3, 200*time.Millisecond).(*phonebookImpl)
addr1 := "addrABC"
addr2 := "addrXYZ"
@@ -315,6 +334,8 @@ func TestWaitAndAddConnectionTimeLongtWindow(t *testing.T) {
}
func TestWaitAndAddConnectionTimeShortWindow(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
entries := MakePhonebook(3, 2*time.Millisecond).(*phonebookImpl)
addr1 := "addrABC"
@@ -367,6 +388,8 @@ func BenchmarkThreadsafePhonebook(b *testing.B) {
// TestPhonebookRoles tests that the filtering by roles for different
// phonebooks entries works as expected.
func TestPhonebookRoles(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
relaysSet := []string{"relay1", "relay2", "relay3"}
archiverSet := []string{"archiver1", "archiver2", "archiver3"}
diff --git a/network/ping_test.go b/network/ping_test.go
index 7cb17c479..85b1ef2c3 100644
--- a/network/ping_test.go
+++ b/network/ping_test.go
@@ -20,11 +20,14 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
// for two node network, check that B can ping A and get a reply
func TestPing(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.config.PeerPingPeriodSeconds = 5
diff --git a/network/requestLogger_test.go b/network/requestLogger_test.go
index 00196a5a9..f65099dc3 100644
--- a/network/requestLogger_test.go
+++ b/network/requestLogger_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/logging/telemetryspec"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type eventsDetailsLogger struct {
@@ -42,6 +43,8 @@ func (dl eventsDetailsLogger) EventWithDetails(category telemetryspec.Category,
// for two node network, check that B can ping A and get a reply
func TestRequestLogger(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
dl := eventsDetailsLogger{Logger: log, eventReceived: make(chan interface{}, 1), eventIdentifier: telemetryspec.HTTPRequestEvent}
log.SetLevel(logging.Level(defaultConfig.BaseLoggerDebugLevel))
diff --git a/network/requestTracker_test.go b/network/requestTracker_test.go
index 067841abc..0016969fa 100644
--- a/network/requestTracker_test.go
+++ b/network/requestTracker_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func (ard *hostIncomingRequests) remove(trackedRequest *TrackerRequest) {
@@ -37,6 +38,8 @@ func (ard *hostIncomingRequests) remove(trackedRequest *TrackerRequest) {
}
}
func TestHostIncomingRequestsOrdering(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if defaultConfig.ConnectionsRateLimitingCount == 0 || defaultConfig.ConnectionsRateLimitingWindowSeconds == 0 {
t.Skip()
}
@@ -70,6 +73,8 @@ func TestHostIncomingRequestsOrdering(t *testing.T) {
}
func TestRateLimiting(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if defaultConfig.ConnectionsRateLimitingCount == 0 || defaultConfig.ConnectionsRateLimitingWindowSeconds == 0 {
t.Skip()
}
@@ -166,6 +171,8 @@ func TestRateLimiting(t *testing.T) {
}
func TestIsLocalHost(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
require.True(t, isLocalhost("localhost"))
require.True(t, isLocalhost("127.0.0.1"))
require.True(t, isLocalhost("[::1]"))
diff --git a/network/topics_test.go b/network/topics_test.go
index a6210a39a..a98d21f2a 100644
--- a/network/topics_test.go
+++ b/network/topics_test.go
@@ -21,11 +21,13 @@ import (
"fmt"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
// Test the marshall/unmarshall of Topics
func TestTopics(t *testing.T) {
+ partitiontest.PartitionTest(t)
topics := Topics{
Topic{
@@ -69,6 +71,7 @@ func TestTopics(t *testing.T) {
// TestCurruptedTopics checks the errors
// Makes sure UnmarshallTopics will not attempt to read beyond the buffer limits
func TestCurruptedTopics(t *testing.T) {
+ partitiontest.PartitionTest(t)
var buffer []byte
diff --git a/network/wsNetwork_test.go b/network/wsNetwork_test.go
index 0eef556b9..55f1e33a5 100644
--- a/network/wsNetwork_test.go
+++ b/network/wsNetwork_test.go
@@ -44,6 +44,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/logging/telemetryspec"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util"
"github.com/algorand/go-algorand/util/metrics"
)
@@ -201,6 +202,8 @@ func newMessageCounter(t testing.TB, target int) *messageCounterHandler {
}
func TestWebsocketNetworkStartStop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.Start()
netA.Stop()
@@ -219,6 +222,8 @@ func waitReady(t testing.TB, wn *WebsocketNetwork, timeout <-chan time.Time) boo
// Set up two nodes, test that a.Broadcast is received by B
func TestWebsocketNetworkBasic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -253,6 +258,8 @@ func TestWebsocketNetworkBasic(t *testing.T) {
// Repeat basic, but test a unicast
func TestWebsocketNetworkUnicast(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -292,6 +299,8 @@ func TestWebsocketNetworkUnicast(t *testing.T) {
// Like a basic test, but really we just want to have SetPeerData()/GetPeerData()
func TestWebsocketPeerData(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -328,6 +337,8 @@ func TestWebsocketPeerData(t *testing.T) {
// Test sending array of messages
func TestWebsocketNetworkArray(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -363,6 +374,8 @@ func TestWebsocketNetworkArray(t *testing.T) {
// Test cancelling message sends
func TestWebsocketNetworkCancel(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -444,6 +457,8 @@ func TestWebsocketNetworkCancel(t *testing.T) {
// Set up two nodes, test that a.Broadcast is received by B, when B has no address.
func TestWebsocketNetworkNoAddress(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -534,6 +549,8 @@ const lineNetworkNumMessages = 5
// Bonus! Measure how long that takes.
// TODO: also make a Benchmark version of this that reports per-node broadcast hop speed.
func TestLineNetwork(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
nodes, counters := lineNetwork(t, lineNetworkLength)
t.Logf("line network length: %d", lineNetworkLength)
waitNodesReady(t, nodes, 2*time.Second)
@@ -568,6 +585,8 @@ func addrtest(t *testing.T, wn *WebsocketNetwork, expected, src string) {
}
func TestAddrToGossipAddr(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
wn := &WebsocketNetwork{}
wn.GenesisID = "test genesisID"
wn.log = logging.Base()
@@ -600,6 +619,8 @@ var nopConnSingleton = nopConn{}
// What happens when all the read message handler threads get busy?
func TestSlowHandlers(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
slowTag := protocol.Tag("sl")
fastTag := protocol.Tag("fa")
slowCounter := messageCounterHandler{shouldWait: 1}
@@ -674,6 +695,8 @@ func TestSlowHandlers(t *testing.T) {
// one peer sends waaaayy too much slow-to-handle traffic. everything else should run fine.
func TestFloodingPeer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("flaky test")
slowTag := protocol.Tag("sl")
fastTag := protocol.Tag("fa")
@@ -767,6 +790,8 @@ func avgSendBufferHighPrioLength(wn *WebsocketNetwork) float64 {
//
// This is a deeply invasive test that reaches into the guts of WebsocketNetwork and wsPeer. If the implementation chainges consider throwing away or totally reimplementing this test.
func TestSlowOutboundPeer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip() // todo - update this test to reflect the new implementation.
xtag := protocol.ProposalPayloadTag
node := makeTestWebsocketNode(t)
@@ -851,6 +876,8 @@ func makeTestFilterWebsocketNode(t *testing.T, nodename string) *WebsocketNetwor
}
func TestDupFilter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestFilterWebsocketNode(t, "a")
netA.config.GossipFanout = 1
netA.Start()
@@ -930,6 +957,8 @@ func TestDupFilter(t *testing.T) {
}
func TestGetPeers(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -1067,6 +1096,8 @@ func BenchmarkWebsocketNetworkBasic(t *testing.B) {
// Check that priority is propagated from B to A
func TestWebsocketNetworkPrio(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
prioA := netPrioStub{}
netA := makeTestWebsocketNode(t)
netA.SetPrioScheme(&prioA)
@@ -1107,6 +1138,8 @@ func TestWebsocketNetworkPrio(t *testing.T) {
// Check that priority is propagated from B to A
func TestWebsocketNetworkPrioLimit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
limitConf := defaultConfig
limitConf.BroadcastConnectionsLimit = 1
@@ -1193,6 +1226,8 @@ func TestWebsocketNetworkPrioLimit(t *testing.T) {
// Create many idle connections, to see if we have excessive CPU utilization.
func TestWebsocketNetworkManyIdle(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// This test is meant to be run manually, as:
//
// IDLETEST=x go test -v . -run=ManyIdle -count=1
@@ -1260,6 +1295,8 @@ func TestWebsocketNetworkManyIdle(t *testing.T) {
// TODO: test funcion when some message handler is slow?
func TestWebsocketNetwork_getCommonHeaders(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
header := http.Header{}
expectedTelemetryGUID := "123"
expectedInstanceName := "456"
@@ -1274,6 +1311,8 @@ func TestWebsocketNetwork_getCommonHeaders(t *testing.T) {
}
func TestWebsocketNetwork_checkServerResponseVariables(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
wn := makeTestWebsocketNode(t)
wn.GenesisID = "genesis-id1"
wn.RandomID = "random-id1"
@@ -1333,6 +1372,8 @@ func (wn *WebsocketNetwork) broadcastWithTimestamp(tag protocol.Tag, data []byte
}
func TestDelayedMessageDrop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.Start()
@@ -1370,6 +1411,8 @@ func TestDelayedMessageDrop(t *testing.T) {
}
func TestSlowPeerDisconnection(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
wn := &WebsocketNetwork{
@@ -1430,6 +1473,8 @@ func TestSlowPeerDisconnection(t *testing.T) {
}
func TestForceMessageRelaying(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
log.SetLevel(logging.Level(defaultConfig.BaseLoggerDebugLevel))
wn := &WebsocketNetwork{
@@ -1513,6 +1558,8 @@ func TestForceMessageRelaying(t *testing.T) {
}
func TestSetUserAgentHeader(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
headers := http.Header{}
SetUserAgentHeader(headers)
require.Equal(t, 1, len(headers))
@@ -1520,6 +1567,8 @@ func TestSetUserAgentHeader(t *testing.T) {
}
func TestCheckProtocolVersionMatch(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// note - this test changes the SupportedProtocolVersions global variable ( SupportedProtocolVersions ) and therefore cannot be parallelized.
originalSupportedProtocolVersions := SupportedProtocolVersions
defer func() {
@@ -1599,6 +1648,8 @@ func handleTopicRequest(msg IncomingMessage) (out OutgoingMessage) {
// Set up two nodes, test topics send/receive is working
func TestWebsocketNetworkTopicRoundtrip(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var topicMsgReqTag Tag = protocol.UniEnsBlockReqTag
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
@@ -1653,6 +1704,8 @@ func TestWebsocketNetworkTopicRoundtrip(t *testing.T) {
// Set up two nodes, have one of them request a certain message tag mask, and verify the other follow that.
func TestWebsocketNetworkMessageOfInterest(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.config.EnablePingHandler = false
@@ -1736,6 +1789,8 @@ func TestWebsocketNetworkMessageOfInterest(t *testing.T) {
// Network B will respond with another message for the first 4 messages. When it receive the 5th message, it would close the connection.
// We want to get an event with disconnectRequestReceived
func TestWebsocketDisconnection(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
netA := makeTestWebsocketNode(t)
netA.config.GossipFanout = 1
netA.config.EnablePingHandler = false
@@ -1823,6 +1878,8 @@ func TestWebsocketDisconnection(t *testing.T) {
// TestASCIIFiltering tests the behaviour of filterASCII by feeding it with few known inputs and verifying the expected outputs.
func TestASCIIFiltering(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testUnicodePrintableStrings := []struct {
testString string
expectedString string
@@ -1863,6 +1920,8 @@ func (cl callbackLogger) Warnf(s string, args ...interface{}) {
// TestMaliciousCheckServerResponseVariables test the checkServerResponseVariables to ensure it doesn't print the a malicious input without being filtered to the log file.
func TestMaliciousCheckServerResponseVariables(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
wn := makeTestWebsocketNode(t)
wn.GenesisID = "genesis-id1"
wn.RandomID = "random-id1"
diff --git a/network/wsPeer_test.go b/network/wsPeer_test.go
index fabfe21b3..0570325b9 100644
--- a/network/wsPeer_test.go
+++ b/network/wsPeer_test.go
@@ -22,10 +22,13 @@ import (
"time"
"unsafe"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestCheckSlowWritingPeer(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
now := time.Now()
peer := wsPeer{
intermittentOutgoingMessageEnqueueTime: 0,
@@ -42,6 +45,8 @@ func TestCheckSlowWritingPeer(t *testing.T) {
// TestGetRequestNonce tests if unique values are generated each time
func TestGetRequestNonce(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numValues := 1000
peer := wsPeer{}
valueChannel := make(chan uint64, numValues)
@@ -74,6 +79,8 @@ func TestGetRequestNonce(t *testing.T) {
}
func TestDefaultMessageTagsLength(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for tag := range defaultSendMessageTags {
require.Equal(t, 2, len(tag))
}
@@ -83,6 +90,8 @@ func TestDefaultMessageTagsLength(t *testing.T) {
// offsets are 64-bit aligned. This is required due to go atomic library
// limitation.
func TestAtomicVariablesAligment(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
p := wsPeer{}
require.True(t, (unsafe.Offsetof(p.requestNonce)%8) == 0)
require.True(t, (unsafe.Offsetof(p.lastPacketTime)%8) == 0)
diff --git a/node/assemble_test.go b/node/assemble_test.go
index 0410d8280..9a6274504 100644
--- a/node/assemble_test.go
+++ b/node/assemble_test.go
@@ -33,6 +33,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var genesisHash = crypto.Digest{0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}
@@ -172,6 +173,8 @@ func (cl callbackLogger) Warnf(s string, args ...interface{}) {
}
func TestAssembleBlockTransactionPoolBehind(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const numUsers = 100
expectingLog := false
baseLog := logging.TestingLog(t)
diff --git a/node/indexer/indexer_test.go b/node/indexer/indexer_test.go
index 6be41dbbe..ce767c695 100644
--- a/node/indexer/indexer_test.go
+++ b/node/indexer/indexer_test.go
@@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type IndexSuite struct {
@@ -150,6 +151,8 @@ func (s *IndexSuite) TestIndexer_Asset() {
}
func TestExampleTestSuite(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
suite.Run(t, new(IndexSuite))
}
diff --git a/node/msgp_gen_test.go b/node/msgp_gen_test.go
index 83ae742df..e72b128ee 100644
--- a/node/msgp_gen_test.go
+++ b/node/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalnetPrioResponse(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := netPrioResponse{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
@@ -71,6 +73,7 @@ func BenchmarkUnmarshalnetPrioResponse(b *testing.B) {
}
func TestMarshalUnmarshalnetPrioResponseSigned(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := netPrioResponseSigned{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/node/node.go b/node/node.go
index 089a303e4..e91b2bc01 100644
--- a/node/node.go
+++ b/node/node.go
@@ -161,7 +161,6 @@ func MakeFull(log logging.Logger, rootDir string, cfg config.Local, phonebookAdd
node := new(AlgorandFullNode)
node.rootDir = rootDir
- node.config = cfg
node.log = log.With("name", cfg.NetAddress)
node.genesisID = genesis.ID()
node.genesisHash = crypto.HashObj(genesis)
@@ -170,6 +169,7 @@ func MakeFull(log logging.Logger, rootDir string, cfg config.Local, phonebookAdd
if node.devMode {
cfg.DisableNetworking = true
}
+ node.config = cfg
// tie network, block fetcher, and agreement services together
p2pNode, err := network.NewWebsocketNetwork(node.log, node.config, phonebookAddresses, genesis.ID(), genesis.Network)
diff --git a/node/node_test.go b/node/node_test.go
index 3fe3be4a9..20a744ad6 100644
--- a/node/node_test.go
+++ b/node/node_test.go
@@ -37,6 +37,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util"
"github.com/algorand/go-algorand/util/db"
"github.com/algorand/go-algorand/util/execpool"
@@ -177,6 +178,8 @@ func setupFullNodes(t *testing.T, proto protocol.ConsensusVersion, verificationP
}
func TestSyncingFullNode(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("This is failing randomly again - PLEASE FIX!")
backlogPool := execpool.MakeBacklog(nil, 0, execpool.LowPriority, nil)
@@ -234,6 +237,8 @@ func TestSyncingFullNode(t *testing.T) {
}
func TestInitialSync(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("flaky TestInitialSync ")
backlogPool := execpool.MakeBacklog(nil, 0, execpool.LowPriority, nil)
@@ -267,6 +272,8 @@ func TestInitialSync(t *testing.T) {
}
func TestSimpleUpgrade(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("Randomly failing: node_test.go:~330 : no block notification for account. Re-enable after agreement bug-fix pass")
backlogPool := execpool.MakeBacklog(nil, 0, execpool.LowPriority, nil)
@@ -416,6 +423,8 @@ func delayStartNode(node *AlgorandFullNode, peers []*AlgorandFullNode, delay tim
}
func TestStatusReport_TimeSinceLastRound(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type fields struct {
LastRoundTimestamp time.Time
}
@@ -472,6 +481,8 @@ func (m mismatchingDirectroyPermissionsLog) Errorf(fmts string, args ...interfac
// TestMismatchingGenesisDirectoryPermissions tests to see that the os.MkDir check we have in MakeFull works as expected. It tests both the return error as well as the logged error.
func TestMismatchingGenesisDirectoryPermissions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testDirectroy, err := ioutil.TempDir(os.TempDir(), t.Name())
require.NoError(t, err)
diff --git a/node/topAccountListener_test.go b/node/topAccountListener_test.go
index 835ef9010..bcacd1ae9 100644
--- a/node/topAccountListener_test.go
+++ b/node/topAccountListener_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// errorString is a trivial implementation of error.
@@ -37,6 +38,8 @@ func (e *errorString) Error() string {
}
func TestUpdateTopAccounts(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var topN []basics.AccountDetail
var input []basics.AccountDetail
@@ -136,6 +139,8 @@ func TestUpdateTopAccounts(t *testing.T) {
}
func TestRemoveSome(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Initialize slice with 100 accounts
var accountsSlice []basics.AccountDetail
for i := 0; i <= 100; i++ {
@@ -176,6 +181,8 @@ func TestRemoveSome(t *testing.T) {
}
func TestUpdate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
listener := topAccountListener{
accounts: []basics.AccountDetail{},
round: 1,
@@ -253,6 +260,8 @@ func TestUpdate(t *testing.T) {
}
func TestInit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
listener := makeTopAccountListener(logging.Base())
// "init" should remove existing values before adding new ones.
diff --git a/nodecontrol/algodControl_test.go b/nodecontrol/algodControl_test.go
index cc53abb84..2349e9c45 100644
--- a/nodecontrol/algodControl_test.go
+++ b/nodecontrol/algodControl_test.go
@@ -20,10 +20,13 @@ import (
"errors"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestStopAlgodErrorNotRunning(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
nodeController := MakeNodeController("", ".")
err := nodeController.StopAlgod()
var e *NodeNotRunningError
@@ -31,6 +34,8 @@ func TestStopAlgodErrorNotRunning(t *testing.T) {
}
func TestStopAlgodErrorInvalidDirectory(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
nodeController := MakeNodeController("", "[][]")
err := nodeController.StopAlgod()
var e *MissingDataDirError
diff --git a/package-deploy.yaml b/package-deploy.yaml
index c6e95ac60..4ad27fb35 100644
--- a/package-deploy.yaml
+++ b/package-deploy.yaml
@@ -64,25 +64,6 @@ agents:
workDir: $HOME/projects/go-algorand
- - name: rpm.centos8
- dockerFilePath: docker/build/cicd.centos8.Dockerfile
- image: algorand/go-algorand-ci-linux-centos8
- version: scripts/configure_dev-deps.sh
- buildArgs:
- - GOLANG_VERSION=`./scripts/get_golang_version.sh`
- env:
- - AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- - AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- - NETWORK=$NETWORK
- - PACKAGES_DIR=$PACKAGES_DIR
- - NO_DEPLOY=$NO_DEPLOY
- - S3_SOURCE=$S3_SOURCE
- - VERSION=$VERSION
- volumes:
- - $XDG_RUNTIME_DIR/gnupg/S.gpg-agent:/root/.gnupg/S.gpg-agent
- - $HOME/.gnupg/pubring.kbx:/root/.gnupg/pubring.kbx
- workDir: $HOME/projects/go-algorand
-
tasks:
- task: docker.Make
name: docker
@@ -104,11 +85,6 @@ tasks:
agent: rpm
target: mule-deploy-rpm
- - task: docker.Make
- name: rpm.centos8
- agent: rpm.centos8
- target: mule-deploy-rpm-centos8
-
jobs:
package-deploy:
tasks:
@@ -124,7 +100,6 @@ jobs:
package-deploy-rpm:
tasks:
- docker.Make.rpm
- - docker.Make.rpm.centos8
docker-hub:
tasks:
diff --git a/package-test.yaml b/package-test.yaml
index 45d844824..e338197ff 100644
--- a/package-test.yaml
+++ b/package-test.yaml
@@ -31,22 +31,6 @@ agents:
- VERSION=$VERSION
workDir: $HOME/projects/go-algorand
- - name: rpm-centos8
- dockerFilePath: docker/build/cicd.centos8.Dockerfile
- image: algorand/mule-linux-centos8
- version: scripts/configure_dev-deps.sh
- buildArgs:
- - GOLANG_VERSION=`./scripts/get_golang_version.sh`
- env:
- - AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- - AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- - BRANCH=$BRANCH
- - NETWORK=$NETWORK
- - S3_SOURCE=$S3_SOURCE
- - SHA=$SHA
- - VERSION=$VERSION
- workDir: $HOME/projects/go-algorand
-
tasks:
- task: docker.Make
name: package-test-deb
@@ -58,17 +42,11 @@ tasks:
agent: rpm
target: mule-test-rpm
- - task: docker.Make
- name: package-test-rpm-centos8
- agent: rpm-centos8
- target: mule-test-rpm-centos8
-
jobs:
package-test:
tasks:
- docker.Make.package-test-deb
- docker.Make.package-test-rpm
- - docker.Make.package-test-rpm-centos8
package-test-deb:
tasks:
@@ -77,5 +55,3 @@ jobs:
package-test-rpm:
tasks:
- docker.Make.package-test-rpm
- - docker.Make.package-test-rpm-centos8
-
diff --git a/package.yaml b/package.yaml
index 7f39cc050..d5d8de0d9 100644
--- a/package.yaml
+++ b/package.yaml
@@ -21,17 +21,6 @@ agents:
- VERSION=$VERSION
workDir: $HOME/projects/go-algorand
- - name: rpm.centos8
- dockerFilePath: docker/build/cicd.centos8.Dockerfile
- image: algorand/go-algorand-ci-linux-centos8
- version: scripts/configure_dev-deps.sh
- buildArgs:
- - GOLANG_VERSION=`./scripts/get_golang_version.sh`
- env:
- - NETWORK=$NETWORK
- - VERSION=$VERSION
- workDir: $HOME/projects/go-algorand
-
- name: docker
dockerFilePath: docker/build/docker.ubuntu.Dockerfile
image: algorand/go-algorand-docker-linux-ubuntu
@@ -57,11 +46,6 @@ tasks:
target: mule-package-rpm
- task: docker.Make
- name: rpm.centos8
- agent: rpm.centos8
- target: mule-package-rpm.centos8
-
- - task: docker.Make
name: deb
agent: deb
target: mule-package-deb
@@ -77,7 +61,6 @@ jobs:
- docker.Make.build
- docker.Make.deb
- docker.Make.rpm
- - docker.Make.rpm.centos8
- docker.Make.docker
package-deb:
@@ -88,7 +71,6 @@ jobs:
tasks:
- docker.Make.build
- docker.Make.rpm
- - docker.Make.rpm.centos8
package-docker:
tasks:
diff --git a/protocol/codec_test.go b/protocol/codec_test.go
index fbc287304..14fef6187 100644
--- a/protocol/codec_test.go
+++ b/protocol/codec_test.go
@@ -18,9 +18,10 @@ package protocol
import (
"reflect"
- "strings"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
+ "github.com/algorand/go-codec/codec"
"github.com/stretchr/testify/require"
)
@@ -54,12 +55,16 @@ type HelperStruct2 struct {
}
func TestOmitEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var x TestStruct
enc := EncodeReflect(&x)
require.Equal(t, 1, len(enc))
}
func TestEncodeOrder(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var a struct {
A int
B string
@@ -117,6 +122,8 @@ type InlineParent struct {
}
func TestEncodeInline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := InlineChild{X: 5}
b := InlineParent{InlineChild: a}
@@ -129,6 +136,8 @@ type embeddedMsgp struct {
}
func TestEncodeEmbedded(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var x embeddedMsgp
x.TxType = PaymentTx
@@ -145,6 +154,8 @@ func TestEncodeEmbedded(t *testing.T) {
}
func TestEncodeJSON(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type ar []string
type mp struct {
Map map[int]ar `codec:"ld,allocbound=config.MaxEvalDeltaAccounts"`
@@ -156,21 +167,35 @@ func TestEncodeJSON(t *testing.T) {
v.Map[1] = []string{"test1"}
nonStrict := EncodeJSON(&v)
- strings.Contains(string(nonStrict), `0:`)
- strings.Contains(string(nonStrict), `1:`)
+ require.Contains(t, string(nonStrict), `0:`)
+ require.Contains(t, string(nonStrict), `1:`)
strict := EncodeJSONStrict(&v)
- strings.Contains(string(strict), `"0":`)
- strings.Contains(string(strict), `"1":`)
+ require.Contains(t, string(strict), `"0":`)
+ require.Contains(t, string(strict), `"1":`)
var nsv mp
err := DecodeJSON(nonStrict, &nsv)
require.NoError(t, err)
var sv mp
- err = DecodeJSON(nonStrict, &sv)
+ err = DecodeJSON(strict, &sv)
require.NoError(t, err)
require.True(t, reflect.DeepEqual(v, nsv))
require.True(t, reflect.DeepEqual(v, sv))
+
+ decodeJSONStrict := func(b []byte, objptr interface{}) error {
+ dec := codec.NewDecoderBytes(b, JSONStrictHandle)
+ return dec.Decode(objptr)
+ }
+
+ nsv = mp{}
+ decodeJSONStrict(nonStrict, &nsv)
+
+ sv = mp{}
+ decodeJSONStrict(strict, &sv)
+
+ require.True(t, reflect.DeepEqual(v, nsv))
+ require.True(t, reflect.DeepEqual(v, sv))
}
diff --git a/protocol/codec_tester.go b/protocol/codec_tester.go
index 66695910e..883b3028f 100644
--- a/protocol/codec_tester.go
+++ b/protocol/codec_tester.go
@@ -24,9 +24,12 @@ import (
"path"
"path/filepath"
"reflect"
+ "runtime"
"strings"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
+
"github.com/algorand/go-deadlock"
"github.com/algorand/msgp/msgp"
@@ -93,6 +96,7 @@ func checkMsgpAllocBoundDirective(dataType reflect.Type) bool {
// does any of the go files in the package directory has the msgp:allocbound defined for that datatype ?
gopath := os.Getenv("GOPATH")
const repositoryRoot = "go-algorand/"
+ const thisFile = "protocol/codec_tester.go"
packageFilesPath := path.Join(gopath, "src", dataType.PkgPath())
if _, err := os.Stat(packageFilesPath); os.IsNotExist(err) {
@@ -104,7 +108,12 @@ func checkMsgpAllocBoundDirective(dataType reflect.Type) bool {
if cwdPaths := strings.SplitAfter(cwd, repositoryRoot); len(cwdPaths) == 2 {
cwd = cwdPaths[0]
} else {
- return false
+ // try to assemble the project directory based on the current stack frame
+ _, file, _, ok := runtime.Caller(0)
+ if !ok {
+ return false
+ }
+ cwd = strings.TrimSuffix(file, thisFile)
}
relPkdPath := strings.SplitAfter(dataType.PkgPath(), repositoryRoot)
@@ -353,6 +362,7 @@ func EncodingTest(template msgpMarshalUnmarshal) error {
// RunEncodingTest runs several iterations of encoding/decoding
// consistency testing of object type specified by template.
func RunEncodingTest(t *testing.T, template msgpMarshalUnmarshal) {
+ partitiontest.PartitionTest(t)
for i := 0; i < 1000; i++ {
err := EncodingTest(template)
if err == errSkipRawMsgpTesting {
diff --git a/protocol/test/allocbound_slice.go b/protocol/test/allocbound_slice.go
new file mode 100644
index 000000000..12ee01dfe
--- /dev/null
+++ b/protocol/test/allocbound_slice.go
@@ -0,0 +1,26 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package test
+
+// used to generate code that might produce this error:
+//
+// Error: Received unexpected error:
+// msgp: length overflow: 29 > 16
+// Test: TestRandomizedEncodingtestSlice
+
+//msgp:allocbound testSlice 16
+type testSlice []uint64
diff --git a/protocol/test/msgp_gen.go b/protocol/test/msgp_gen.go
new file mode 100644
index 000000000..ac8ec8b74
--- /dev/null
+++ b/protocol/test/msgp_gen.go
@@ -0,0 +1,87 @@
+package test
+
+// Code generated by github.com/algorand/msgp DO NOT EDIT.
+
+import (
+ "github.com/algorand/msgp/msgp"
+)
+
+// The following msgp objects are implemented in this file:
+// testSlice
+// |-----> MarshalMsg
+// |-----> CanMarshalMsg
+// |-----> (*) UnmarshalMsg
+// |-----> (*) CanUnmarshalMsg
+// |-----> Msgsize
+// |-----> MsgIsZero
+//
+
+// MarshalMsg implements msgp.Marshaler
+func (z testSlice) MarshalMsg(b []byte) (o []byte) {
+ o = msgp.Require(b, z.Msgsize())
+ if z == nil {
+ o = msgp.AppendNil(o)
+ } else {
+ o = msgp.AppendArrayHeader(o, uint32(len(z)))
+ }
+ for za0001 := range z {
+ o = msgp.AppendUint64(o, z[za0001])
+ }
+ return
+}
+
+func (_ testSlice) CanMarshalMsg(z interface{}) bool {
+ _, ok := (z).(testSlice)
+ if !ok {
+ _, ok = (z).(*testSlice)
+ }
+ return ok
+}
+
+// UnmarshalMsg implements msgp.Unmarshaler
+func (z *testSlice) UnmarshalMsg(bts []byte) (o []byte, err error) {
+ var zb0002 int
+ var zb0003 bool
+ zb0002, zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts)
+ if err != nil {
+ err = msgp.WrapError(err)
+ return
+ }
+ if zb0002 > 16 {
+ err = msgp.ErrOverflow(uint64(zb0002), uint64(16))
+ err = msgp.WrapError(err)
+ return
+ }
+ if zb0003 {
+ (*z) = nil
+ } else if (*z) != nil && cap((*z)) >= zb0002 {
+ (*z) = (*z)[:zb0002]
+ } else {
+ (*z) = make(testSlice, zb0002)
+ }
+ for zb0001 := range *z {
+ (*z)[zb0001], bts, err = msgp.ReadUint64Bytes(bts)
+ if err != nil {
+ err = msgp.WrapError(err, zb0001)
+ return
+ }
+ }
+ o = bts
+ return
+}
+
+func (_ *testSlice) CanUnmarshalMsg(z interface{}) bool {
+ _, ok := (z).(*testSlice)
+ return ok
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z testSlice) Msgsize() (s int) {
+ s = msgp.ArrayHeaderSize + (len(z) * (msgp.Uint64Size))
+ return
+}
+
+// MsgIsZero returns whether this is a zero value
+func (z testSlice) MsgIsZero() bool {
+ return len(z) == 0
+}
diff --git a/protocol/test/msgp_gen_test.go b/protocol/test/msgp_gen_test.go
new file mode 100644
index 000000000..d87b778e0
--- /dev/null
+++ b/protocol/test/msgp_gen_test.go
@@ -0,0 +1,73 @@
+// +build !skip_msgp_testing
+
+package test
+
+// Code generated by github.com/algorand/msgp DO NOT EDIT.
+
+import (
+ "testing"
+
+ "github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
+ "github.com/algorand/msgp/msgp"
+)
+
+func TestMarshalUnmarshaltestSlice(t *testing.T) {
+ partitiontest.PartitionTest(t)
+ v := testSlice{}
+ bts := v.MarshalMsg(nil)
+ left, err := v.UnmarshalMsg(bts)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(left) > 0 {
+ t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
+ }
+
+ left, err = msgp.Skip(bts)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(left) > 0 {
+ t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
+ }
+}
+
+func TestRandomizedEncodingtestSlice(t *testing.T) {
+ protocol.RunEncodingTest(t, &testSlice{})
+}
+
+func BenchmarkMarshalMsgtestSlice(b *testing.B) {
+ v := testSlice{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalMsg(nil)
+ }
+}
+
+func BenchmarkAppendMsgtestSlice(b *testing.B) {
+ v := testSlice{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts = v.MarshalMsg(bts[0:0])
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts = v.MarshalMsg(bts[0:0])
+ }
+}
+
+func BenchmarkUnmarshaltestSlice(b *testing.B) {
+ v := testSlice{}
+ bts := v.MarshalMsg(nil)
+ b.ReportAllocs()
+ b.SetBytes(int64(len(bts)))
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ _, err := v.UnmarshalMsg(bts)
+ if err != nil {
+ b.Fatal(err)
+ }
+ }
+}
diff --git a/protocol/transcode/core_test.go b/protocol/transcode/core_test.go
index 57c74635f..330ea6655 100644
--- a/protocol/transcode/core_test.go
+++ b/protocol/transcode/core_test.go
@@ -27,6 +27,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func transcodeNoError(t *testing.T, mpToJSON bool, in io.ReadCloser, out io.WriteCloser) {
@@ -164,6 +165,8 @@ func randomMap(width int, depth int) interface{} {
}
func TestIdempotence(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
niter := 10000
if testing.Short() {
niter = 1000
@@ -176,6 +179,8 @@ func TestIdempotence(t *testing.T) {
}
func TestIdempotenceMultiobject(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
niter := 1000
if testing.Short() {
niter = 100
@@ -211,6 +216,8 @@ type parentStruct struct {
}
func TestIdempotenceStruct(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
niter := 10000
if testing.Short() {
niter = 1000
diff --git a/rpcs/blockService.go b/rpcs/blockService.go
index 677446a7f..c5b3668d7 100644
--- a/rpcs/blockService.go
+++ b/rpcs/blockService.go
@@ -188,8 +188,6 @@ func (bs *BlockService) ServeHTTP(response http.ResponseWriter, request *http.Re
response.WriteHeader(http.StatusBadRequest)
return
}
- } else {
- versionStr = "1"
}
}
round, err := strconv.ParseUint(roundStr, 36, 64)
diff --git a/rpcs/blockService_test.go b/rpcs/blockService_test.go
index 343e5571c..3269f5c13 100644
--- a/rpcs/blockService_test.go
+++ b/rpcs/blockService_test.go
@@ -33,6 +33,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type mockUnicastPeer struct {
@@ -58,6 +59,7 @@ func (mup *mockUnicastPeer) Respond(ctx context.Context, reqMsg network.Incoming
// TestHandleCatchupReqNegative covers the error reporting in handleCatchupReq
func TestHandleCatchupReqNegative(t *testing.T) {
+ partitiontest.PartitionTest(t)
reqMsg := network.IncomingMessage{
Sender: &mockUnicastPeer{},
@@ -112,6 +114,8 @@ func TestHandleCatchupReqNegative(t *testing.T) {
// TestRedirectBasic tests the case when the block service redirects the request to elsewhere
func TestRedirectFallbackArchiver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
ledger1 := makeLedger(t, "l1")
@@ -164,6 +168,8 @@ func TestRedirectFallbackArchiver(t *testing.T) {
// TestRedirectBasic tests the case when the block service redirects the request to elsewhere
func TestRedirectFallbackEndpoints(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
ledger1 := makeLedger(t, "l1")
@@ -216,6 +222,8 @@ func TestRedirectFallbackEndpoints(t *testing.T) {
// - the case when the peer is not a valid http peer
// - the case when the block service keeps redirecting and cannot get a block
func TestRedirectExceptions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
log := logging.TestingLog(t)
ledger1 := makeLedger(t, "l1")
diff --git a/rpcs/ledgerService.go b/rpcs/ledgerService.go
index 3aa32bbd2..8a8500c57 100644
--- a/rpcs/ledgerService.go
+++ b/rpcs/ledgerService.go
@@ -163,8 +163,6 @@ func (ls *LedgerService) ServeHTTP(response http.ResponseWriter, request *http.R
response.Write([]byte(fmt.Sprintf("invalid number of version specified %d", len(versionStrs))))
return
}
- } else {
- versionStr = "1"
}
}
round, err := strconv.ParseUint(roundStr, 36, 64)
diff --git a/rpcs/msgp_gen_test.go b/rpcs/msgp_gen_test.go
index 8501c3c81..46ec99aaf 100644
--- a/rpcs/msgp_gen_test.go
+++ b/rpcs/msgp_gen_test.go
@@ -8,10 +8,12 @@ import (
"testing"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/msgp/msgp"
)
func TestMarshalUnmarshalEncodedBlockCert(t *testing.T) {
+ partitiontest.PartitionTest(t)
v := EncodedBlockCert{}
bts := v.MarshalMsg(nil)
left, err := v.UnmarshalMsg(bts)
diff --git a/rpcs/txService_test.go b/rpcs/txService_test.go
index b43ea7f91..fd92b83a1 100644
--- a/rpcs/txService_test.go
+++ b/rpcs/txService_test.go
@@ -34,6 +34,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/bloom"
)
@@ -132,6 +133,8 @@ func nodePair() (*basicRPCNode, *basicRPCNode) {
}
func TestTxSync(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// A network with two nodes, A and B
nodeA, nodeB := nodePair()
defer nodeA.stop()
diff --git a/rpcs/txSyncer_test.go b/rpcs/txSyncer_test.go
index 69b517806..c141eb7bb 100644
--- a/rpcs/txSyncer_test.go
+++ b/rpcs/txSyncer_test.go
@@ -36,6 +36,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/bloom"
)
@@ -163,6 +164,8 @@ func makeMockClientAggregator(t *testing.T, failWithNil bool, failWithError bool
}
func TestSyncFromClient(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
clientPool := makeMockPendingTxAggregate(2)
serverPool := makeMockPendingTxAggregate(1)
runner := mockRunner{failWithNil: false, failWithError: false, txgroups: serverPool.PendingTxGroups()[len(serverPool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
@@ -177,6 +180,8 @@ func TestSyncFromClient(t *testing.T) {
}
func TestSyncFromUnsupportedClient(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pool := makeMockPendingTxAggregate(3)
runner := mockRunner{failWithNil: true, failWithError: false, txgroups: pool.PendingTxGroups()[len(pool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
client := mockRPCClient{client: &runner, log: logging.TestingLog(t)}
@@ -190,6 +195,8 @@ func TestSyncFromUnsupportedClient(t *testing.T) {
}
func TestSyncFromClientAndQuit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pool := makeMockPendingTxAggregate(3)
runner := mockRunner{failWithNil: false, failWithError: false, txgroups: pool.PendingTxGroups()[len(pool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
client := mockRPCClient{client: &runner, log: logging.TestingLog(t)}
@@ -203,6 +210,7 @@ func TestSyncFromClientAndQuit(t *testing.T) {
}
func TestSyncFromClientAndError(t *testing.T) {
+ partitiontest.PartitionTest(t)
pool := makeMockPendingTxAggregate(3)
runner := mockRunner{failWithNil: false, failWithError: true, txgroups: pool.PendingTxGroups()[len(pool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
@@ -216,6 +224,8 @@ func TestSyncFromClientAndError(t *testing.T) {
}
func TestSyncFromClientAndTimeout(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pool := makeMockPendingTxAggregate(3)
runner := mockRunner{failWithNil: false, failWithError: false, txgroups: pool.PendingTxGroups()[len(pool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
client := mockRPCClient{client: &runner, log: logging.TestingLog(t)}
@@ -229,6 +239,8 @@ func TestSyncFromClientAndTimeout(t *testing.T) {
}
func TestSync(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pool := makeMockPendingTxAggregate(1)
nodeA := basicRPCNode{}
txservice := makeTxService(pool, "test genesisID", config.GetDefaultLocal().TxPoolSize, config.GetDefaultLocal().TxSyncServeResponseSize)
@@ -249,6 +261,8 @@ func TestSync(t *testing.T) {
}
func TestNoClientsSync(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pool := makeMockPendingTxAggregate(3)
clientAgg := mockClientAggregator{peers: []network.Peer{}}
handler := mockHandler{}
@@ -260,6 +274,8 @@ func TestNoClientsSync(t *testing.T) {
}
func TestStartAndStop(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("TODO: replace this test in new client paradigm")
pool := makeMockPendingTxAggregate(3)
runner := mockRunner{failWithNil: false, failWithError: false, txgroups: pool.PendingTxGroups()[len(pool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
@@ -289,6 +305,8 @@ func TestStartAndStop(t *testing.T) {
}
func TestStartAndQuit(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
pool := makeMockPendingTxAggregate(3)
runner := mockRunner{failWithNil: false, failWithError: false, txgroups: pool.PendingTxGroups()[len(pool.PendingTxGroups())-1:], done: make(chan *rpc.Call)}
client := mockRPCClient{client: &runner, log: logging.TestingLog(t)}
diff --git a/scripts/buildtools/go.mod b/scripts/buildtools/go.mod
index 314a9dd5b..785b0819d 100644
--- a/scripts/buildtools/go.mod
+++ b/scripts/buildtools/go.mod
@@ -3,7 +3,7 @@ module github.com/algorand/go-algorand/scripts/buildtools
go 1.14
require (
- github.com/algorand/msgp v1.1.47
+ github.com/algorand/msgp v1.1.48
github.com/go-swagger/go-swagger v0.25.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/tools v0.1.1 // indirect
diff --git a/scripts/buildtools/go.sum b/scripts/buildtools/go.sum
index f545004ce..e912f0710 100644
--- a/scripts/buildtools/go.sum
+++ b/scripts/buildtools/go.sum
@@ -21,8 +21,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
-github.com/algorand/msgp v1.1.47 h1:xeU6G/Mb1iudJe4L5X38YrOY+VHhvHQDZXxyXYHTzOw=
-github.com/algorand/msgp v1.1.47/go.mod h1:LtOntbYiCHj/Sl/Sqxtf8CZOrDt2a8Dv3tLaS6mcnUE=
+github.com/algorand/msgp v1.1.48 h1:5P+gVmTnk0m37r+rA3ZsFZW219ZqmCLulW5f8Z+3nx8=
+github.com/algorand/msgp v1.1.48/go.mod h1:LtOntbYiCHj/Sl/Sqxtf8CZOrDt2a8Dv3tLaS6mcnUE=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
diff --git a/scripts/configure_dev.sh b/scripts/configure_dev.sh
index 39bf352ba..6eb00df3d 100755
--- a/scripts/configure_dev.sh
+++ b/scripts/configure_dev.sh
@@ -72,16 +72,20 @@ if [ "${OS}" = "linux" ]; then
sudo "$SCRIPTPATH/install_linux_deps.sh"
fi
elif [ "${OS}" = "darwin" ]; then
- brew update
- brew tap homebrew/cask
+ if [ "${CIRCLECI}" != "true" ]; then
+ brew update
+ brew tap homebrew/cask
+ fi
install_or_upgrade pkg-config
install_or_upgrade boost
- install_or_upgrade jq
install_or_upgrade libtool
- install_or_upgrade autoconf
- install_or_upgrade automake
install_or_upgrade shellcheck
- install_or_upgrade python3
+ if [ "${CIRCLECI}" != "true" ]; then
+ install_or_upgrade jq
+ install_or_upgrade autoconf
+ install_or_upgrade automake
+ install_or_upgrade python3
+ fi
elif [ "${OS}" = "windows" ]; then
if ! $msys2 pacman -S --disable-download-timeout --noconfirm git automake autoconf m4 libtool make mingw-w64-x86_64-gcc mingw-w64-x86_64-boost mingw-w64-x86_64-python mingw-w64-x86_64-jq unzip procps; then
echo "Error installing pacman dependencies"
diff --git a/scripts/release/build/rpm/docker.sh b/scripts/release/build/rpm/docker.sh
index f198728e7..ab748b50f 100755
--- a/scripts/release/build/rpm/docker.sh
+++ b/scripts/release/build/rpm/docker.sh
@@ -9,7 +9,6 @@ echo
set -ex
sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/package.sh"
-sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentos8build /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/package.sh"
echo
date "+build_release end PACKAGE RPM stage %Y%m%d_%H%M%S"
diff --git a/scripts/release/build/stage/build/task.sh b/scripts/release/build/stage/build/task.sh
index 4d1612bfc..fdb96d6b2 100755
--- a/scripts/release/build/stage/build/task.sh
+++ b/scripts/release/build/stage/build/task.sh
@@ -30,14 +30,10 @@ else
echo ${BUILD_NUMBER} > "${REPO_ROOT}"/buildnumber.dat
fi
-# Run RPM build in Centos7 Docker container
+# Run RPM build in Centos 7 & 8 Docker container
sg docker "docker build -t algocentosbuild - < $HOME/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile"
sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/build.sh"
-# Run RPM build in Centos8 Docker container
-sg docker "docker build -t algocentos8build - < $HOME/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos8.Dockerfile"
-sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=${HOME},dst=/root/subhome algocentos8build /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/build.sh"
-
echo
date "+build_release end BUILD stage %Y%m%d_%H%M%S"
echo
diff --git a/scripts/release/build/stage/package/task.sh b/scripts/release/build/stage/package/task.sh
index 34d47216f..9685fca5e 100755
--- a/scripts/release/build/stage/package/task.sh
+++ b/scripts/release/build/stage/package/task.sh
@@ -13,7 +13,6 @@ echo
"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/build/deb/package.sh
sg docker "docker run --rm --env-file $HOME/build_env_docker --mount type=bind,src=$HOME,dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/package.sh"
-sg docker "docker run --rm --env-file $HOME/build_env_docker --mount type=bind,src=$HOME,dst=/root/subhome algocentos8build /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/build/rpm/package.sh"
echo
date "+build_release end PACKAGE stage %Y%m%d_%H%M%S"
diff --git a/scripts/release/mule/test/test.sh b/scripts/release/mule/test/test.sh
index 90a8998be..aed2a5110 100755
--- a/scripts/release/mule/test/test.sh
+++ b/scripts/release/mule/test/test.sh
@@ -93,7 +93,11 @@ else
# We need to install this since it's not being installed by a package manager.
# Normally, this is installed for us b/c it's a dependency.
# See `./installer/rpm/algorand/algorand.spec`.
- dnf install dnf-automatic -y
+ if command -v dnf &>/dev/null; then
+ dnf install dnf-automatic -y
+ else
+ yum install dnf-automatic -y
+ fi
#
# Note that the RPM package DOES NOT have the CHANNEL in its filename (unlike DEB),
# instead it contains the package name.
diff --git a/scripts/release/prod/rpm/run_centos.sh b/scripts/release/prod/rpm/run_centos.sh
index c98e1ada2..9426da5ea 100755
--- a/scripts/release/prod/rpm/run_centos.sh
+++ b/scripts/release/prod/rpm/run_centos.sh
@@ -5,12 +5,8 @@ set -ex
. "${HOME}"/build_env
-# Run RPM build in Centos7 Docker container
+# Run RPM build in Centos 7 & 8 Docker container
sg docker "docker build -t algocentosbuild - < ${HOME}/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile"
sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/prodrepo,dst=/root/prodrepo --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/prod/rpm/snapshot.sh"
-# Run RPM build in Centos8 Docker container
-sg docker "docker build -t algocentos8build - < ${HOME}/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos8.Dockerfile"
-
-sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/prodrepo,dst=/root/prodrepo --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentos8build /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/prod/rpm/snapshot.sh"
diff --git a/scripts/release/test/rpm/run_centos.sh b/scripts/release/test/rpm/run_centos.sh
index 2c6470011..88e0a6be4 100755
--- a/scripts/release/test/rpm/run_centos.sh
+++ b/scripts/release/test/rpm/run_centos.sh
@@ -14,10 +14,8 @@ if [ "$CHANNEL" = beta ]; then
exit 0
fi
-# Run RPM build in Centos7 Docker container
+# Run RPM build in Centos 7 & 8 Docker container
sg docker "docker build -t algocentosbuild - < ${HOME}/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos.Dockerfile"
-# Run RPM build in Centos8 Docker container
-sg docker "docker build -t algocentos8build - < ${HOME}/go/src/github.com/algorand/go-algorand/scripts/release/common/docker/centos8.Dockerfile"
cat <<EOF>"${HOME}"/dummyrepo/algodummy.repo
[algodummy]
@@ -32,7 +30,6 @@ cd "${HOME}"/dummyrepo && python3 "${HOME}"/go/src/github.com/algorand/go-algora
trap "${HOME}"/go/src/github.com/algorand/go-algorand/scripts/kill_httpd.sh 0
sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/dummyrepo,dst=/root/dummyrepo --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentosbuild /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/test/rpm/test_algorand.sh"
-sg docker "docker run --rm --env-file ${HOME}/build_env_docker --mount type=bind,src=/run/user/1000/gnupg/S.gpg-agent,dst=/root/S.gpg-agent --mount type=bind,src=${HOME}/dummyrepo,dst=/root/dummyrepo --mount type=bind,src=${HOME}/keys,dst=/root/keys --mount type=bind,src=${HOME},dst=/root/subhome algocentos8build /root/subhome/go/src/github.com/algorand/go-algorand/scripts/release/test/rpm/test_algorand.sh"
echo
date "+build_release end TEST stage %Y%m%d_%H%M%S"
diff --git a/scripts/travis/before_build.sh b/scripts/travis/before_build.sh
index 197866629..b07efe33f 100755
--- a/scripts/travis/before_build.sh
+++ b/scripts/travis/before_build.sh
@@ -18,7 +18,9 @@ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
OS=$("${SCRIPTPATH}"/../ostype.sh)
ARCH=$("${SCRIPTPATH}"/../archtype.sh)
-echo "Building libsodium-fork..."
-make crypto/libs/${OS}/${ARCH}/lib/libsodium.a
+if [ ! -f crypto/libs/${OS}/${ARCH}/lib/libsodium.a ]; then
+ echo "Building libsodium-fork..."
+ make crypto/libs/${OS}/${ARCH}/lib/libsodium.a
+fi
diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh
index 62457b785..991e25c5b 100755
--- a/scripts/travis/build.sh
+++ b/scripts/travis/build.sh
@@ -44,11 +44,12 @@ OS=$("${SCRIPTPATH}/../ostype.sh")
ARCH=$("${SCRIPTPATH}/../archtype.sh")
# Get the go build version.
-GOLANG_VERSION=$(./scripts/get_golang_version.sh)
-
-curl -sL -o ~/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
-chmod +x ~/gimme
-eval "$(~/gimme "${GOLANG_VERSION}")"
+if [ -z "${NO_GIMME}" ]; then
+ GOLANG_VERSION=$(./scripts/get_golang_version.sh)
+ curl -sL -o ~/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
+ chmod +x ~/gimme
+ eval "$(~/gimme "${GOLANG_VERSION}")"
+fi
# travis sometimes fail to download a dependency. trying multiple times might help.
for (( attempt=1; attempt<=5; attempt++ ))
diff --git a/scripts/travis/configure_dev.sh b/scripts/travis/configure_dev.sh
index ed8e8b203..a45a5a713 100755
--- a/scripts/travis/configure_dev.sh
+++ b/scripts/travis/configure_dev.sh
@@ -21,9 +21,11 @@ if [[ "${OS}" == "linux" ]]; then
elif [[ "${OS}" == "darwin" ]]; then
# we don't want to upgrade boost if we already have it, as it will try to update
# other components.
- brew update
- brew tap homebrew/cask
- brew pin boost || true
+ if [ "${CIRCLECI}" != "true" ]; then
+ brew update
+ brew tap homebrew/cask
+ brew pin boost || true
+ fi
elif [[ "${OS}" == "windows" ]]; then
git config --global core.autocrlf true
# Golang probably is not installed under MSYS2 so add the environment variable temporarily
diff --git a/scripts/travis/test.sh b/scripts/travis/test.sh
index 011a970bd..629fc683b 100755
--- a/scripts/travis/test.sh
+++ b/scripts/travis/test.sh
@@ -8,11 +8,12 @@ OS=$("${SCRIPTPATH}/../ostype.sh")
ARCH=$("${SCRIPTPATH}/../archtype.sh")
# Get the go build version.
-GOLANG_VERSION=$(./scripts/get_golang_version.sh)
-
-curl -sL -o ~/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
-chmod +x ~/gimme
-eval "$(~/gimme "${GOLANG_VERSION}")"
+if [ -z "${NO_GIMME}" ]; then
+ GOLANG_VERSION=$(./scripts/get_golang_version.sh)
+ curl -sL -o ~/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
+ chmod +x ~/gimme
+ eval "$(~/gimme "${GOLANG_VERSION}")"
+fi
# If this command fails the Makefile will select 'go test' instead.
"${SCRIPTPATH}/../buildtools/install_buildtools.sh" -o "gotest.tools/gotestsum" || true
diff --git a/shared/pingpong/accounts.go b/shared/pingpong/accounts.go
index 3e499e90e..4cb68f0c2 100644
--- a/shared/pingpong/accounts.go
+++ b/shared/pingpong/accounts.go
@@ -80,7 +80,6 @@ func ensureAccounts(ac libgoal.Client, initCfg PpConfig) (accounts map[string]ui
}
if richestBalance >= cfg.MinAccountFunds {
- srcAcctPresent = true
cfg.SrcAccount = richestAccount
fmt.Printf("Identified richest account to use for Source Account: %s -> %v\n", richestAccount, richestBalance)
diff --git a/shared/pingpong/pingpong.go b/shared/pingpong/pingpong.go
index 81feac1cf..45051fa9d 100644
--- a/shared/pingpong/pingpong.go
+++ b/shared/pingpong/pingpong.go
@@ -153,10 +153,7 @@ func computeAccountMinBalance(client libgoal.Client, cfg PpConfig) (requiredBala
fmt.Printf("required min balance for app accounts: %d\n", requiredBalance)
return
}
- var fee uint64 = 1000
- if cfg.MinFee > fee {
- fee = cfg.MinFee
- }
+ var fee uint64
if cfg.MaxFee != 0 {
fee = cfg.MaxFee
} else {
diff --git a/test/commandandcontrol/cc_agent/component/agent_test.go b/test/commandandcontrol/cc_agent/component/agent_test.go
index cfa738a01..0fb21f0dc 100644
--- a/test/commandandcontrol/cc_agent/component/agent_test.go
+++ b/test/commandandcontrol/cc_agent/component/agent_test.go
@@ -19,10 +19,13 @@ package component
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/assert"
)
func TestCommandStatus(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var start = START
var completed = COMPLETED
var failed = FAILED
diff --git a/test/e2e-go/cli/algod/cleanup_test.go b/test/e2e-go/cli/algod/cleanup_test.go
index 310a8e82d..ed8b8d0dd 100644
--- a/test/e2e-go/cli/algod/cleanup_test.go
+++ b/test/e2e-go/cli/algod/cleanup_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/nodecontrol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestNodeControllerCleanup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/cli/algod/stdstreams_test.go b/test/e2e-go/cli/algod/stdstreams_test.go
index 27b87fcb8..8e77ffd6c 100644
--- a/test/e2e-go/cli/algod/stdstreams_test.go
+++ b/test/e2e-go/cli/algod/stdstreams_test.go
@@ -24,10 +24,13 @@ import (
"github.com/algorand/go-algorand/nodecontrol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util"
)
func TestAlgodLogsToFile(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fixture fixtures.LibGoalFixture
diff --git a/test/e2e-go/cli/tealdbg/cdtmock/main.go b/test/e2e-go/cli/tealdbg/cdtmock/main.go
index f8de6fd94..fa2791ea0 100644
--- a/test/e2e-go/cli/tealdbg/cdtmock/main.go
+++ b/test/e2e-go/cli/tealdbg/cdtmock/main.go
@@ -87,9 +87,9 @@ func main() {
os.Exit(1)
}
- var counter int64 = 1
- req := cdt.ChromeRequest{ID: counter, Method: "Debugger.Enable"}
+ var counter int64
counter++
+ req := cdt.ChromeRequest{ID: counter, Method: "Debugger.Enable"}
if err = client.SendJSON(req); err != nil {
fmt.Printf("Send error: %v", err)
@@ -101,8 +101,8 @@ func main() {
}
fmt.Printf("%s\n", string(data))
- req = cdt.ChromeRequest{ID: counter, Method: "Runtime.runIfWaitingForDebugger"}
counter++
+ req = cdt.ChromeRequest{ID: counter, Method: "Runtime.runIfWaitingForDebugger"}
if err = client.SendJSON(req); err != nil {
fmt.Printf("Send error: %v", err)
@@ -114,8 +114,8 @@ func main() {
}
fmt.Printf("%s\n", string(data))
- req = cdt.ChromeRequest{ID: counter, Method: "Debugger.resume"}
counter++
+ req = cdt.ChromeRequest{ID: counter, Method: "Debugger.resume"}
if err = client.SendJSON(req); err != nil {
fmt.Printf("Send error: %v", err)
diff --git a/test/e2e-go/features/catchup/basicCatchup_test.go b/test/e2e-go/features/catchup/basicCatchup_test.go
index 32370a928..ebb8870e2 100644
--- a/test/e2e-go/features/catchup/basicCatchup_test.go
+++ b/test/e2e-go/features/catchup/basicCatchup_test.go
@@ -28,9 +28,12 @@ import (
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestBasicCatchup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -76,6 +79,8 @@ func TestBasicCatchup(t *testing.T) {
// TestCatchupOverGossip tests catchup across network versions
// The current versions are the original v1 and the upgraded to v2.1
func TestCatchupOverGossip(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
syncTest := fixtures.SynchronizedTest(t)
@@ -195,6 +200,8 @@ const consensusTestUnupgradedProtocol = protocol.ConsensusVersion("test-unupgrad
const consensusTestUnupgradedToProtocol = protocol.ConsensusVersion("test-unupgradedto-protocol")
func TestStoppedCatchupOnUnsupported(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
diff --git a/test/e2e-go/features/catchup/catchpointCatchup_test.go b/test/e2e-go/features/catchup/catchpointCatchup_test.go
index 6865bebfa..3d1e35ef2 100644
--- a/test/e2e-go/features/catchup/catchpointCatchup_test.go
+++ b/test/e2e-go/features/catchup/catchpointCatchup_test.go
@@ -35,6 +35,7 @@ import (
"github.com/algorand/go-algorand/nodecontrol"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type nodeExitErrorCollector struct {
@@ -79,6 +80,8 @@ func (ec *nodeExitErrorCollector) Print() {
}
func TestBasicCatchpointCatchup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
diff --git a/test/e2e-go/features/compactcert/compactcert_test.go b/test/e2e-go/features/compactcert/compactcert_test.go
index 1bff175fc..e5f35c4fa 100644
--- a/test/e2e-go/features/compactcert/compactcert_test.go
+++ b/test/e2e-go/features/compactcert/compactcert_test.go
@@ -32,9 +32,12 @@ import (
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/rpcs"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestCompactCerts(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip("Disabling since they need work and shouldn't block releases")
t.Parallel()
r := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/multisig/multisig_test.go b/test/e2e-go/features/multisig/multisig_test.go
index 8a086b89d..7e4958674 100644
--- a/test/e2e-go/features/multisig/multisig_test.go
+++ b/test/e2e-go/features/multisig/multisig_test.go
@@ -23,6 +23,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -31,6 +32,8 @@ import (
// try to transact with 2 sigs: expect success
// try to transact with 3 sigs: expect success
func TestBasicMultisig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fixture fixtures.RestClientFixture
@@ -106,6 +109,8 @@ func TestBasicMultisig(t *testing.T) {
// create a 0-of-3 multisig address: expect failure
func TestZeroThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fixture fixtures.RestClientFixture
@@ -133,6 +138,8 @@ func TestZeroThreshold(t *testing.T) {
// create a 3-of-0 multisig address: expect failure
func TestZeroSigners(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fixture fixtures.RestClientFixture
@@ -156,6 +163,8 @@ func TestZeroSigners(t *testing.T) {
// where the valid keys are all the same
// then try to transact
func TestDuplicateKeys(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
var fixture fixtures.RestClientFixture
diff --git a/test/e2e-go/features/participation/onlineOfflineParticipation_test.go b/test/e2e-go/features/participation/onlineOfflineParticipation_test.go
index 2c822f6f9..bcb2b5551 100644
--- a/test/e2e-go/features/participation/onlineOfflineParticipation_test.go
+++ b/test/e2e-go/features/participation/onlineOfflineParticipation_test.go
@@ -29,9 +29,12 @@ import (
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/e2e-go/globals"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestParticipationKeyOnlyAccountParticipatesCorrectly(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -104,6 +107,7 @@ func waitForAccountToProposeBlock(a *require.Assertions, fixture *fixtures.RestC
// it should not be proposing blocks
// - When the account balance receives enough stake, it should be proposing after lookback rounds
func TestNewAccountCanGoOnlineAndParticipate(t *testing.T) {
+ partitiontest.PartitionTest(t)
if testing.Short() {
t.Skip()
}
diff --git a/test/e2e-go/features/participation/overlappingParticipationKeys_test.go b/test/e2e-go/features/participation/overlappingParticipationKeys_test.go
index 6f4082a0f..e3b9ca45b 100644
--- a/test/e2e-go/features/participation/overlappingParticipationKeys_test.go
+++ b/test/e2e-go/features/participation/overlappingParticipationKeys_test.go
@@ -35,10 +35,13 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/db"
)
func TestOverlappingParticipationKeys(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/participation/participationRewards_test.go b/test/e2e-go/features/participation/participationRewards_test.go
index be6d661cc..6faa5c7b3 100644
--- a/test/e2e-go/features/participation/participationRewards_test.go
+++ b/test/e2e-go/features/participation/participationRewards_test.go
@@ -19,6 +19,7 @@ package participation
import (
"fmt"
"path/filepath"
+ "runtime"
"testing"
"github.com/stretchr/testify/require"
@@ -27,6 +28,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func getFirstAccountFromNamedNode(fixture *fixtures.RestClientFixture, r *require.Assertions, nodeName string) (account string) {
@@ -75,6 +77,8 @@ func spendToNonParticipating(t *testing.T, fixture *fixtures.RestClientFixture,
}
func TestOnlineOfflineRewards(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
r := require.New(fixtures.SynchronizedTest(t))
@@ -131,6 +135,11 @@ func TestOnlineOfflineRewards(t *testing.T) {
}
func TestPartkeyOnlyRewards(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
+ if runtime.GOOS == "darwin" {
+ t.Skip()
+ }
if testing.Short() {
t.Skip()
}
@@ -177,6 +186,8 @@ func TestPartkeyOnlyRewards(t *testing.T) {
}
func TestRewardUnitThreshold(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
r := require.New(fixtures.SynchronizedTest(t))
@@ -296,6 +307,8 @@ func TestRewardUnitThreshold(t *testing.T) {
var defaultPoolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
func TestRewardRateRecalculation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
r := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/partitionRecovery/partitionRecovery_test.go b/test/e2e-go/features/partitionRecovery/partitionRecovery_test.go
index 813ee3216..7e7823093 100644
--- a/test/e2e-go/features/partitionRecovery/partitionRecovery_test.go
+++ b/test/e2e-go/features/partitionRecovery/partitionRecovery_test.go
@@ -24,12 +24,15 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
const partitionRecoveryTime = 20 * time.Minute // If we hit step 9, worst case recovery time can be ~2^8 * 5 ~= 20 mins
const inducePartitionTime = 6 * time.Second // Try to minimize change of proceeding too many steps while stalled
func TestBasicPartitionRecovery(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -74,6 +77,8 @@ func TestBasicPartitionRecovery(t *testing.T) {
}
func TestPartitionRecoverySwapStartup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -94,6 +99,8 @@ func TestPartitionRecoverySwapStartup(t *testing.T) {
}
func TestPartitionRecoveryStaggerRestart(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -155,6 +162,8 @@ func runTestWithStaggeredStopStart(t *testing.T, fixture *fixtures.RestClientFix
}
func TestBasicPartitionRecoveryPartOffline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -206,6 +215,8 @@ func TestBasicPartitionRecoveryPartOffline(t *testing.T) {
}
func TestPartitionHalfOffline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
diff --git a/test/e2e-go/features/teal/compile_test.go b/test/e2e-go/features/teal/compile_test.go
index 16822febd..f042d318f 100644
--- a/test/e2e-go/features/teal/compile_test.go
+++ b/test/e2e-go/features/teal/compile_test.go
@@ -25,9 +25,12 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestTealCompile(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
diff --git a/test/e2e-go/features/transactions/accountv2_test.go b/test/e2e-go/features/transactions/accountv2_test.go
index bef5baace..a0b0db464 100644
--- a/test/e2e-go/features/transactions/accountv2_test.go
+++ b/test/e2e-go/features/transactions/accountv2_test.go
@@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/libgoal"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func checkEvalDelta(t *testing.T, client *libgoal.Client, startRnd, endRnd uint64, gval uint64, lval uint64) {
@@ -75,6 +76,8 @@ func checkEvalDelta(t *testing.T, client *libgoal.Client, startRnd, endRnd uint6
}
func TestAccountInformationV2(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/transactions/asset_test.go b/test/e2e-go/features/transactions/asset_test.go
index 9606d3130..ca09258f5 100644
--- a/test/e2e-go/features/transactions/asset_test.go
+++ b/test/e2e-go/features/transactions/asset_test.go
@@ -31,6 +31,7 @@ import (
"github.com/algorand/go-algorand/libgoal"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type assetIDParams struct {
@@ -53,6 +54,8 @@ func helperFillSignBroadcast(client libgoal.Client, wh []byte, sender string, tx
}
func TestAssetValidRounds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -184,6 +187,8 @@ func TestAssetValidRounds(t *testing.T) {
}
func TestAssetConfig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
@@ -419,6 +424,8 @@ func TestAssetConfig(t *testing.T) {
}
func TestAssetInformation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -511,6 +518,8 @@ func TestAssetInformation(t *testing.T) {
}
func TestAssetGroupCreateSendDestroy(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -652,6 +661,8 @@ func TestAssetGroupCreateSendDestroy(t *testing.T) {
}
func TestAssetSend(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -899,6 +910,8 @@ func TestAssetSend(t *testing.T) {
}
func TestAssetCreateWaitRestartDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a, fixture, client, account0 := setupTestAndNetwork(t, "", nil)
defer fixture.Shutdown()
@@ -960,6 +973,8 @@ func TestAssetCreateWaitRestartDelete(t *testing.T) {
}
func TestAssetCreateWaitBalLookbackDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
if testing.Short() {
t.Skip()
}
diff --git a/test/e2e-go/features/transactions/close_account_test.go b/test/e2e-go/features/transactions/close_account_test.go
index 66f1a0138..a1be10b0b 100644
--- a/test/e2e-go/features/transactions/close_account_test.go
+++ b/test/e2e-go/features/transactions/close_account_test.go
@@ -23,9 +23,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestAccountsCanClose(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/transactions/group_test.go b/test/e2e-go/features/transactions/group_test.go
index b13929f2f..47f30ffc0 100644
--- a/test/e2e-go/features/transactions/group_test.go
+++ b/test/e2e-go/features/transactions/group_test.go
@@ -27,9 +27,12 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestGroupTransactions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -100,6 +103,8 @@ func TestGroupTransactions(t *testing.T) {
}
func TestGroupTransactionsDifferentSizes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -206,6 +211,8 @@ func TestGroupTransactionsDifferentSizes(t *testing.T) {
}
func TestGroupTransactionsSubmission(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/transactions/lease_test.go b/test/e2e-go/features/transactions/lease_test.go
index 571776f37..3e96cee5c 100644
--- a/test/e2e-go/features/transactions/lease_test.go
+++ b/test/e2e-go/features/transactions/lease_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestLeaseTransactionsSameSender(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -86,6 +89,8 @@ func TestLeaseTransactionsSameSender(t *testing.T) {
}
func TestLeaseRegressionFaultyFirstValidCheckOld_2f3880f7(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -158,6 +163,8 @@ func TestLeaseRegressionFaultyFirstValidCheckOld_2f3880f7(t *testing.T) {
}
func TestLeaseRegressionFaultyFirstValidCheckNew_2f3880f7(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -217,6 +224,8 @@ func TestLeaseRegressionFaultyFirstValidCheckNew_2f3880f7(t *testing.T) {
}
func TestLeaseTransactionsSameSenderDifferentLease(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -278,6 +287,8 @@ func TestLeaseTransactionsSameSenderDifferentLease(t *testing.T) {
}
func TestLeaseTransactionsDifferentSender(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
@@ -352,6 +363,8 @@ func TestLeaseTransactionsDifferentSender(t *testing.T) {
}
func TestOverlappingLeases(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/transactions/onlineStatusChange_test.go b/test/e2e-go/features/transactions/onlineStatusChange_test.go
index c56c75f18..d4f153fc1 100644
--- a/test/e2e-go/features/transactions/onlineStatusChange_test.go
+++ b/test/e2e-go/features/transactions/onlineStatusChange_test.go
@@ -24,16 +24,21 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
const transactionValidityPeriod = uint64(100) // rounds
const transactionFee = uint64(0)
func TestAccountsCanChangeOnlineState(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanChangeOnlineState(t, filepath.Join("nettemplates", "TwoNodesPartlyOffline.json"))
}
func TestAccountsCanChangeOnlineStateInTheFuture(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanChangeOnlineState(t, filepath.Join("nettemplates", "TwoNodesPartlyOfflineVFuture.json"))
}
diff --git a/test/e2e-go/features/transactions/proof_test.go b/test/e2e-go/features/transactions/proof_test.go
index c604c2b2b..76c144dd5 100644
--- a/test/e2e-go/features/transactions/proof_test.go
+++ b/test/e2e-go/features/transactions/proof_test.go
@@ -26,9 +26,12 @@ import (
"github.com/algorand/go-algorand/crypto/merklearray"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestTxnMerkleProof(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/features/transactions/sendReceive_test.go b/test/e2e-go/features/transactions/sendReceive_test.go
index 700e6215b..0c0ac5cf6 100644
--- a/test/e2e-go/features/transactions/sendReceive_test.go
+++ b/test/e2e-go/features/transactions/sendReceive_test.go
@@ -25,6 +25,7 @@ import (
v1 "github.com/algorand/go-algorand/daemon/algod/api/spec/v1"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func GenerateRandomBytes(n int) []byte {
@@ -41,6 +42,8 @@ func GenerateRandomBytes(n int) []byte {
// this test checks that two accounts' balances stay up to date
// as they send each other money many times
func TestAccountsCanSendMoney(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numberOfSends := 25
if testing.Short() {
numberOfSends = 3
diff --git a/test/e2e-go/kmd/e2e_kmd_server_client_test.go b/test/e2e-go/kmd/e2e_kmd_server_client_test.go
index cb7c13c25..3aa417558 100644
--- a/test/e2e-go/kmd/e2e_kmd_server_client_test.go
+++ b/test/e2e-go/kmd/e2e_kmd_server_client_test.go
@@ -25,9 +25,12 @@ import (
"github.com/algorand/go-algorand/daemon/kmd/client"
"github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestServerStartsStopsSuccessfully(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -42,6 +45,8 @@ func TestServerStartsStopsSuccessfully(t *testing.T) {
}
func TestBadAuthFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
var f fixtures.KMDFixture
@@ -61,6 +66,8 @@ func TestBadAuthFails(t *testing.T) {
}
func TestGoodAuthSucceeds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
diff --git a/test/e2e-go/kmd/e2e_kmd_sqlite_test.go b/test/e2e-go/kmd/e2e_kmd_sqlite_test.go
index 63dda845d..a724e1e28 100644
--- a/test/e2e-go/kmd/e2e_kmd_sqlite_test.go
+++ b/test/e2e-go/kmd/e2e_kmd_sqlite_test.go
@@ -23,9 +23,12 @@ import (
"github.com/algorand/go-algorand/daemon/kmd/config"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestNonAbsSQLiteWalletConfigFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -42,6 +45,8 @@ func TestNonAbsSQLiteWalletConfigFails(t *testing.T) {
}
func TestAbsSQLiteWalletConfigSucceeds(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
diff --git a/test/e2e-go/kmd/e2e_kmd_wallet_keyops_test.go b/test/e2e-go/kmd/e2e_kmd_wallet_keyops_test.go
index b119f716f..18c7f6d10 100644
--- a/test/e2e-go/kmd/e2e_kmd_wallet_keyops_test.go
+++ b/test/e2e-go/kmd/e2e_kmd_wallet_keyops_test.go
@@ -29,9 +29,12 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestGenerateAndListKeys(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -84,6 +87,8 @@ func TestGenerateAndListKeys(t *testing.T) {
}
func TestImportKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -134,6 +139,8 @@ func TestImportKey(t *testing.T) {
}
func TestExportKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -196,6 +203,8 @@ func TestExportKey(t *testing.T) {
}
func TestDeleteKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -260,6 +269,8 @@ func TestDeleteKey(t *testing.T) {
}
func TestSignTransaction(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -318,6 +329,8 @@ func TestSignTransaction(t *testing.T) {
}
func TestSignProgram(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -417,6 +430,8 @@ func BenchmarkSignTransaction(b *testing.B) {
}
func TestMasterKeyImportExport(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -584,6 +599,8 @@ func TestMasterKeyImportExport(t *testing.T) {
}
func TestMasterKeyGeneratePastImportedKeys(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
diff --git a/test/e2e-go/kmd/e2e_kmd_wallet_multisig_test.go b/test/e2e-go/kmd/e2e_kmd_wallet_multisig_test.go
index 3a5576a6e..95598721d 100644
--- a/test/e2e-go/kmd/e2e_kmd_wallet_multisig_test.go
+++ b/test/e2e-go/kmd/e2e_kmd_wallet_multisig_test.go
@@ -29,6 +29,7 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func addrToPK(t *testing.T, addr string) crypto.PublicKey {
@@ -39,6 +40,8 @@ func addrToPK(t *testing.T, addr string) crypto.PublicKey {
}
func TestMultisigImportList(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -86,6 +89,8 @@ func TestMultisigImportList(t *testing.T) {
}
func TestMultisigExportDelete(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -156,6 +161,8 @@ func TestMultisigExportDelete(t *testing.T) {
}
func TestMultisigSign(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -229,6 +236,8 @@ func TestMultisigSign(t *testing.T) {
}
func TestMultisigSignWithSigner(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -309,6 +318,8 @@ func TestMultisigSignWithSigner(t *testing.T) {
}
func TestMultisigSignWithWrongSigner(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -366,6 +377,8 @@ func TestMultisigSignWithWrongSigner(t *testing.T) {
}
func TestMultisigSignProgram(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
diff --git a/test/e2e-go/kmd/e2e_kmd_wallet_test.go b/test/e2e-go/kmd/e2e_kmd_wallet_test.go
index e0c7ccd9b..26eabc0e8 100644
--- a/test/e2e-go/kmd/e2e_kmd_wallet_test.go
+++ b/test/e2e-go/kmd/e2e_kmd_wallet_test.go
@@ -24,9 +24,12 @@ import (
"github.com/algorand/go-algorand/daemon/kmd/lib/kmdapi"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestWalletCreation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -77,6 +80,8 @@ func TestWalletCreation(t *testing.T) {
}
func TestBlankWalletCreation(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -110,6 +115,8 @@ func TestBlankWalletCreation(t *testing.T) {
}
func TestWalletRename(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -188,6 +195,8 @@ func TestWalletRename(t *testing.T) {
}
func TestWalletSessionRelease(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -228,6 +237,8 @@ func TestWalletSessionRelease(t *testing.T) {
}
func TestWalletSessionRenew(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
@@ -274,6 +285,8 @@ func TestWalletSessionRenew(t *testing.T) {
}
func TestWalletSessionExpiry(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
t.Parallel()
var f fixtures.KMDFixture
diff --git a/test/e2e-go/restAPI/restClient_test.go b/test/e2e-go/restAPI/restClient_test.go
index d6e03a9a0..3c3faa2d0 100644
--- a/test/e2e-go/restAPI/restClient_test.go
+++ b/test/e2e-go/restAPI/restClient_test.go
@@ -42,6 +42,7 @@ import (
"github.com/algorand/go-algorand/libgoal"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
var fixture fixtures.RestClientFixture
@@ -186,6 +187,8 @@ func waitForTransaction(t *testing.T, testClient libgoal.Client, fromAddress, tx
}
func TestClientCanGetStatus(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -200,6 +203,8 @@ func TestClientCanGetStatus(t *testing.T) {
}
func TestClientCanGetStatusAfterBlock(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -213,6 +218,8 @@ func TestClientCanGetStatusAfterBlock(t *testing.T) {
}
func TestTransactionsByAddr(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
localFixture.Setup(t, filepath.Join("nettemplates", "TwoNodes50Each.json"))
@@ -259,6 +266,8 @@ func TestTransactionsByAddr(t *testing.T) {
}
func TestClientCanGetVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -268,6 +277,8 @@ func TestClientCanGetVersion(t *testing.T) {
}
func TestClientCanGetSuggestedFee(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -277,6 +288,8 @@ func TestClientCanGetSuggestedFee(t *testing.T) {
}
func TestClientCanGetMinTxnFee(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -286,6 +299,8 @@ func TestClientCanGetMinTxnFee(t *testing.T) {
}
func TestClientCanGetBlockInfo(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -296,6 +311,8 @@ func TestClientCanGetBlockInfo(t *testing.T) {
}
func TestClientRejectsBadFromAddressWhenSending(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -310,6 +327,8 @@ func TestClientRejectsBadFromAddressWhenSending(t *testing.T) {
}
func TestClientRejectsBadToAddressWhenSending(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -324,6 +343,8 @@ func TestClientRejectsBadToAddressWhenSending(t *testing.T) {
}
func TestClientRejectsMutatedFromAddressWhenSending(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -345,6 +366,8 @@ func TestClientRejectsMutatedFromAddressWhenSending(t *testing.T) {
}
func TestClientRejectsMutatedToAddressWhenSending(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -366,6 +389,8 @@ func TestClientRejectsMutatedToAddressWhenSending(t *testing.T) {
}
func TestClientRejectsSendingMoneyFromAccountForWhichItHasNoKey(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -380,6 +405,8 @@ func TestClientRejectsSendingMoneyFromAccountForWhichItHasNoKey(t *testing.T) {
}
func TestClientOversizedNote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -403,6 +430,8 @@ func TestClientOversizedNote(t *testing.T) {
}
func TestClientCanSendAndGetNote(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -426,6 +455,8 @@ func TestClientCanSendAndGetNote(t *testing.T) {
}
func TestClientCanGetTransactionStatus(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -448,6 +479,8 @@ func TestClientCanGetTransactionStatus(t *testing.T) {
}
func TestAccountBalance(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -475,6 +508,8 @@ func TestAccountBalance(t *testing.T) {
}
func TestAccountParticipationInfo(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -536,6 +571,8 @@ func TestAccountParticipationInfo(t *testing.T) {
}
func TestSupply(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -547,6 +584,8 @@ func TestSupply(t *testing.T) {
}
func TestClientCanGetGoRoutines(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.AlgodClient
@@ -559,6 +598,8 @@ func TestClientCanGetGoRoutines(t *testing.T) {
}
func TestSendingTooMuchFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -598,6 +639,8 @@ func TestSendingTooMuchFails(t *testing.T) {
}
func TestSendingFromEmptyAccountFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -635,6 +678,8 @@ func TestSendingFromEmptyAccountFails(t *testing.T) {
}
func TestSendingTooLittleToEmptyAccountFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -665,6 +710,8 @@ func TestSendingTooLittleToEmptyAccountFails(t *testing.T) {
}
func TestSendingLowFeeFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
testClient := fixture.LibGoalClient
@@ -698,6 +745,8 @@ func TestSendingLowFeeFails(t *testing.T) {
}
func TestSendingNotClosingAccountFails(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
// use a local fixture because we might really mess with the balances
var localFixture fixtures.RestClientFixture
@@ -742,6 +791,8 @@ func TestSendingNotClosingAccountFails(t *testing.T) {
}
func TestClientCanGetPendingTransactions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
localFixture.Setup(t, filepath.Join("nettemplates", "TwoNodes50Each.json"))
@@ -773,6 +824,8 @@ func TestClientCanGetPendingTransactions(t *testing.T) {
}
func TestClientTruncatesPendingTransactions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
localFixture.Setup(t, filepath.Join("nettemplates", "TwoNodes50Each.json"))
@@ -810,3 +863,45 @@ func TestClientTruncatesPendingTransactions(t *testing.T) {
}
a.True(len(txIDsSeen) == NumTxns-MaxTxns)
}
+
+func TestClientPrioritizesPendingTransactions(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
+ t.Skip("new FIFO pool does not have prioritization")
+ a := require.New(fixtures.SynchronizedTest(t))
+ var localFixture fixtures.RestClientFixture
+ localFixture.Setup(t, filepath.Join("nettemplates", "TwoNodes50Each.json"))
+ defer localFixture.Shutdown()
+
+ testClient := localFixture.LibGoalClient
+ wh, _ := testClient.GetUnencryptedWalletHandle()
+ addresses, _ := testClient.ListAddresses(wh)
+ fromAddress := addresses[0]
+ toAddress, _ := testClient.GenerateAddress(wh)
+ nc, _ := localFixture.GetNodeController("Node")
+ err := nc.FullStop()
+ a.NoError(err)
+
+ minTxnFee, minAcctBalance, err := localFixture.CurrentMinFeeAndBalance()
+ a.NoError(err)
+
+ NumTxns := 5
+ MaxTxns := 3
+ for i := 0; i < NumTxns; i++ {
+ toAddress2, _ := testClient.GenerateAddress(wh)
+ _, err := testClient.SendPaymentFromUnencryptedWallet(fromAddress, toAddress2, minTxnFee, minAcctBalance, nil)
+ a.NoError(err)
+ }
+
+ // Add a very high fee transaction. This should have first priority
+ // (even if we don't know the encoding length of the underlying signed txn)
+ txHigh, err := testClient.SendPaymentFromUnencryptedWallet(fromAddress, toAddress, minTxnFee*10, minAcctBalance, nil)
+ a.NoError(err)
+
+ statusResponse, err := testClient.GetPendingTransactions(uint64(MaxTxns))
+ a.NoError(err)
+ a.NotEmpty(statusResponse)
+ a.True(int(statusResponse.TotalTxns) == NumTxns+1)
+ a.True(len(statusResponse.TruncatedTxns.Transactions) == MaxTxns)
+ a.True(statusResponse.TruncatedTxns.Transactions[0].TxID == txHigh.ID().String())
+}
diff --git a/test/e2e-go/stress/transactions/createManyAndGoOnline_test.go b/test/e2e-go/stress/transactions/createManyAndGoOnline_test.go
index bb09714f9..9e8ce85a6 100644
--- a/test/e2e-go/stress/transactions/createManyAndGoOnline_test.go
+++ b/test/e2e-go/stress/transactions/createManyAndGoOnline_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/libgoal"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func cascadeCreateAndFundAccounts(amountToSend, transactionFee uint64, fundingAccount string, client libgoal.Client, a *require.Assertions) map[string]string {
@@ -48,6 +49,8 @@ func cascadeCreateAndFundAccounts(amountToSend, transactionFee uint64, fundingAc
// this test creates many accounts
// sends them all money, and sends them online
func TestManyAccountsCanGoOnline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Parallel()
a := require.New(fixtures.SynchronizedTest(t))
diff --git a/test/e2e-go/upgrades/application_support_test.go b/test/e2e-go/upgrades/application_support_test.go
index 79b60fb31..6b0827b4e 100644
--- a/test/e2e-go/upgrades/application_support_test.go
+++ b/test/e2e-go/upgrades/application_support_test.go
@@ -29,6 +29,7 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// consensusTestUnupgradedProtocol is a version of ConsensusCurrentVersion
@@ -70,6 +71,8 @@ func makeApplicationUpgradeConsensus(t *testing.T) (appConsensus config.Consensu
// to a version that supports applications. It verify that prior to supporting applications, the node would not accept
// any application transaction and after the upgrade is complete, it would support that.
func TestApplicationsUpgradeOverREST(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
smallLambdaMs := 500
consensus := makeApplicationUpgradeConsensus(t)
@@ -298,6 +301,8 @@ int 1
// to a version that supports applications. It verify that prior to supporting applications, the node would not accept
// any application transaction and after the upgrade is complete, it would support that.
func TestApplicationsUpgradeOverGossip(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
smallLambdaMs := 500
consensus := makeApplicationUpgradeConsensus(t)
diff --git a/test/e2e-go/upgrades/rekey_support_test.go b/test/e2e-go/upgrades/rekey_support_test.go
index eaed76c70..b7c11284f 100644
--- a/test/e2e-go/upgrades/rekey_support_test.go
+++ b/test/e2e-go/upgrades/rekey_support_test.go
@@ -27,10 +27,13 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
// TestRekeyUpgrade tests that the rekey does not work before the upgrade and works well after
func TestRekeyUpgrade(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(fixtures.SynchronizedTest(t))
smallLambdaMs := 500
diff --git a/test/e2e-go/upgrades/send_receive_upgrade_test.go b/test/e2e-go/upgrades/send_receive_upgrade_test.go
index 0d7228061..f7b58949a 100644
--- a/test/e2e-go/upgrades/send_receive_upgrade_test.go
+++ b/test/e2e-go/upgrades/send_receive_upgrade_test.go
@@ -27,6 +27,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/framework/fixtures"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func GenerateRandomBytes(n int) []byte {
@@ -43,22 +44,32 @@ func GenerateRandomBytes(n int) []byte {
// this test checks that two accounts can send money to one another
// across a protocol upgrade.
func TestAccountsCanSendMoneyAcrossUpgradeV15toV16(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanSendMoneyAcrossUpgrade(t, filepath.Join("nettemplates", "TwoNodes50EachV15Upgrade.json"))
}
func TestAccountsCanSendMoneyAcrossUpgradeV21toV22(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanSendMoneyAcrossUpgrade(t, filepath.Join("nettemplates", "TwoNodes50EachV21Upgrade.json"))
}
func TestAccountsCanSendMoneyAcrossUpgradeV22toV23(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanSendMoneyAcrossUpgrade(t, filepath.Join("nettemplates", "TwoNodes50EachV22Upgrade.json"))
}
func TestAccountsCanSendMoneyAcrossUpgradeV23toV24(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanSendMoneyAcrossUpgrade(t, filepath.Join("nettemplates", "TwoNodes50EachV23Upgrade.json"))
}
func TestAccountsCanSendMoneyAcrossUpgradeV24toV25(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
testAccountsCanSendMoneyAcrossUpgrade(t, filepath.Join("nettemplates", "TwoNodes50EachV24Upgrade.json"))
}
diff --git a/test/framework/fixtures/expectFixture.go b/test/framework/fixtures/expectFixture.go
index 602c6bbbf..3620c1368 100644
--- a/test/framework/fixtures/expectFixture.go
+++ b/test/framework/fixtures/expectFixture.go
@@ -28,6 +28,7 @@ import (
"strings"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -115,6 +116,8 @@ func (ef *ExpectFixture) Run() {
for testName := range ef.expectFiles {
if match, _ := regexp.MatchString(ef.testFilter, testName); match {
ef.t.Run(testName, func(t *testing.T) {
+ partitiontest.PartitionTest(t) // Check if this expect test should by run, may SKIP
+
syncTest := SynchronizedTest(t)
workingDir, algoDir, err := ef.getTestDir(testName)
require.NoError(SynchronizedTest(t), err)
diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go
index 3f390e61c..0aea3989c 100644
--- a/test/framework/fixtures/libgoalFixture.go
+++ b/test/framework/fixtures/libgoalFixture.go
@@ -152,7 +152,6 @@ func (f *LibGoalFixture) importRootKeys(lg *libgoal.Client, dataDir string) {
handle, err = db.MakeAccessor(filepath.Join(keyDir, filename), false, false)
if err != nil {
// Couldn't open it, skip it
- err = nil
continue
}
@@ -160,7 +159,6 @@ func (f *LibGoalFixture) importRootKeys(lg *libgoal.Client, dataDir string) {
root, err := account.RestoreRoot(handle)
if err != nil {
// Couldn't read it, skip it
- err = nil
continue
}
@@ -177,7 +175,6 @@ func (f *LibGoalFixture) importRootKeys(lg *libgoal.Client, dataDir string) {
handle, err = db.MakeErasableAccessor(filepath.Join(keyDir, filename))
if err != nil {
// Couldn't open it, skip it
- err = nil
continue
}
@@ -185,7 +182,6 @@ func (f *LibGoalFixture) importRootKeys(lg *libgoal.Client, dataDir string) {
participation, err := account.RestoreParticipation(handle)
if err != nil {
// Couldn't read it, skip it
- err = nil
handle.Close()
continue
}
@@ -224,6 +220,7 @@ func (f *LibGoalFixture) GetLibGoalClientFromDataDir(dataDir string) libgoal.Cli
// GetLibGoalClientForNamedNode returns the LibGoal Client for a given named node
func (f *LibGoalFixture) GetLibGoalClientForNamedNode(nodeName string) libgoal.Client {
nodeDir, err := f.network.GetNodeDir(nodeName)
+ f.failOnError(err, "network.GetNodeDir failed: %v")
client, err := libgoal.MakeClientWithBinDir(f.binDir, nodeDir, nodeDir, libgoal.KmdClient)
f.failOnError(err, "make libgoal client failed: %v")
f.importRootKeys(&client, nodeDir)
@@ -245,6 +242,7 @@ func (f *LibGoalFixture) GetLibGoalClientFromDataDirNoKeys(dataDir string) libgo
// GetLibGoalClientForNamedNodeNoKeys returns the LibGoal Client for a given named node
func (f *LibGoalFixture) GetLibGoalClientForNamedNodeNoKeys(nodeName string) libgoal.Client {
nodeDir, err := f.network.GetNodeDir(nodeName)
+ f.failOnError(err, "network.GetNodeDir failed: %v")
client, err := libgoal.MakeClientWithBinDir(f.binDir, nodeDir, nodeDir, libgoal.AlgodClient)
f.failOnError(err, "make libgoal client failed: %v")
return client
diff --git a/test/heapwatch/metrics_delta.py b/test/heapwatch/metrics_delta.py
index 249d8da65..80d914838 100644
--- a/test/heapwatch/metrics_delta.py
+++ b/test/heapwatch/metrics_delta.py
@@ -162,9 +162,24 @@ class summary:
lines.append('{}\t{:.0f}\t{:.0f}'.format(msg, txBps, rxBps))
return '\n'.join(lines)
+ def txPool(self):
+ mins = []
+ maxs = []
+ means = []
+ for nick, ns in self.nodes.items():
+ if len(ns.txPool) < 2:
+ continue
+ # skip the first two while the system could still count as warming up
+ txp = ns.txPool[2:]
+ mins.append(min(txp))
+ maxs.append(max(txp))
+ means.append(statistics.mean(txp))
+ return 'txnpool({} {} {} {} {})'.format(
+ min(mins), min(means), statistics.mean(means), max(means), max(maxs)
+ )
def __str__(self):
- return '{}\nsummary: {:0.2f} TPS, {:0.0f} tx B/s, {:0.0f} rx B/s'.format(self.byMsg(), self.tpsMeanSum/self.sumsCount, self.txBpsMeanSum/self.sumsCount, self.rxBpsMeanSum/self.sumsCount)
+ return '{}\n{}\nsummary: {:0.2f} TPS, {:0.0f} tx B/s, {:0.0f} rx B/s'.format(self.byMsg(), self.txPool(), self.tpsMeanSum/self.sumsCount, self.txBpsMeanSum/self.sumsCount, self.rxBpsMeanSum/self.sumsCount)
def anynickre(nick_re, nicks):
if not nick_re:
@@ -279,6 +294,7 @@ def perProtocol(prefix, lists, sums, deltas, dt):
sums[sub] = sums.get(sub,0) + v
def process_files(args, nick, paths):
+ "returns a nodestats object"
return nodestats().process_files(args, nick, paths)
class nodestats:
@@ -299,8 +315,11 @@ class nodestats:
# algod_network_sent_bytes_*
self.txPLists = {}
self.txPSums = {}
+ # algod_tx_pool_count{}
+ self.txPool = []
def process_files(self, args, nick=None, metrics_files=None):
+ "returns self, a nodestats object"
self.args = args
self.nick = nick
if metrics_files is None:
@@ -333,6 +352,7 @@ class nodestats:
with open(bijsonpath, 'rt') as fin:
bi = json.load(fin)
curtime = os.path.getmtime(path)
+ self.txPool.append(cur.get('algod_tx_pool_count{}'))
#logger.debug('%s: %r', path, cur)
if prev is not None:
d = metrics_delta(prev, cur)
diff --git a/test/partitiontest/filtering.go b/test/partitiontest/filtering.go
new file mode 100644
index 000000000..74a263aaa
--- /dev/null
+++ b/test/partitiontest/filtering.go
@@ -0,0 +1,55 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package partitiontest
+
+import (
+ "hash/fnv"
+ "os"
+ "runtime"
+ "strconv"
+ "testing"
+)
+
+// PartitionTest checks if the current partition should run this test, and skips it if not.
+func PartitionTest(t *testing.T) {
+ pt, found := os.LookupEnv("PARTITION_TOTAL")
+ if !found {
+ return
+ }
+ partitions, err := strconv.Atoi(pt)
+ if err != nil {
+ return
+ }
+ pid := os.Getenv("PARTITION_ID")
+ partitionID, err := strconv.Atoi(pid)
+ if err != nil {
+ return
+ }
+ name := t.Name()
+ _, file, _, _ := runtime.Caller(1) // get filename of caller to PartitionTest
+ nameNumber := stringToUint64(file + ":" + name)
+ idx := nameNumber % uint64(partitions)
+ if idx != uint64(partitionID) {
+ t.Skipf("skipping %s due to partitioning: assigned to %d but I am %d of %d", name, idx, partitionID, partitions)
+ }
+}
+
+func stringToUint64(str string) uint64 {
+ h := fnv.New64a()
+ h.Write([]byte(str))
+ return h.Sum64()
+}
diff --git a/test/scripts/e2e.sh b/test/scripts/e2e.sh
index a951bb8fc..8a0362149 100755
--- a/test/scripts/e2e.sh
+++ b/test/scripts/e2e.sh
@@ -100,6 +100,8 @@ export GOPATH=$(go env GOPATH)
# Change current directory to test/scripts so we can just use ./test.sh to exec.
cd "${SCRIPT_PATH}"
+if [ "${SKIP_E2E_SUBS}" = "" ]; then
+
./timeout 200 ./e2e_basic_start_stop.sh
duration "e2e_basic_start_stop.sh"
@@ -124,6 +126,12 @@ duration "serial client runners"
deactivate
+fi # if $SKIP_E2E_SUBS = ""
+
+if [ "${E2E_SUBS_ONLY}" != "" ]; then
+ exit 0
+fi
+
# Export our root temp folder as 'TESTDIR' for tests to use as their root test folder
# This allows us to clean up everything with our rm -rf trap.
export TESTDIR=${TEMPDIR}
diff --git a/test/scripts/e2e_subs/e2e-app-extra-pages.sh b/test/scripts/e2e_subs/e2e-app-extra-pages.sh
index 0fafa3256..9c32cef59 100755
--- a/test/scripts/e2e_subs/e2e-app-extra-pages.sh
+++ b/test/scripts/e2e_subs/e2e-app-extra-pages.sh
@@ -42,10 +42,14 @@ function generate_teal() {
BIG_TEAL_FILE="$TEMPDIR/big-app.teal"
BIG_TEAL_V4_FILE="$TEMPDIR/big-app-v4.teal"
SMALL_TEAL_FILE="$TEMPDIR/sm-app.teal"
+APPR_PROG="$TEMPDIR/appr-prog.teal"
+BIG_APPR_PROG="$TEMPDIR/big-appr-prog.teal"
generate_teal "$BIG_TEAL_FILE" 3 4090 1 "int 0\nbalance\npop\n"
generate_teal "$BIG_TEAL_V4_FILE" 4 4090 1 "int 0\nbalance\npop\n"
generate_teal "$SMALL_TEAL_FILE" 3 10 1 "int 0\nbalance\npop\n"
+generate_teal "$APPR_PROG" 4 3072 1 "int 0\nbalance\npop\n"
+generate_teal "$BIG_APPR_PROG" 4 4098 1 "int 0\nbalance\npop\n"
# App create fails. Approval program too long
RES=$(${gcmd} app create --creator ${ACCOUNT} --approval-prog "${BIG_TEAL_FILE}" --clear-prog "${BIG_TEAL_FILE}" --global-byteslices 1 --global-ints 0 --local-byteslices 0 --local-ints 0 2>&1 || true)
@@ -79,5 +83,34 @@ if [[ $RES != *"${EXPERROR}"* ]]; then
false
fi
-# App create with extra pages, succeedd
+# App create with extra pages, succeeded
${gcmd} app create --creator ${ACCOUNT} --approval-prog "${SMALL_TEAL_FILE}" --clear-prog "${SMALL_TEAL_FILE}" --extra-pages 1 --global-byteslices 1 --global-ints 0 --local-byteslices 0 --local-ints 0
+
+# App update
+RES=$(${gcmd} app create --creator ${ACCOUNT} --approval-prog "${SMALL_TEAL_FILE}" --clear-prog "${SMALL_TEAL_FILE}" --extra-pages 1 --global-byteslices 1 --global-ints 0 --local-byteslices 0 --local-ints 0 2>&1 || true)
+EXP="Created app"
+APPID=$(echo $RES | awk '{print $NF}')
+if [[ $RES != *"${EXP}"* ]]; then
+ date '+app-extra-pages-test FAIL the application creation should pass %Y%m%d_%H%M%S'
+ false
+fi
+
+RES=$(${gcmd} app info --app-id ${APPID} 2>&1 || true)
+PROGHASH="Approval hash: 7356635AKR4FJOOKXXBWNN6HDJ5U3O2YWAOSK6NZBPMOGIQSWCL2N74VT4"
+if [[ $RES != *"${PROGHASH}"* ]]; then
+ date '+app-extra-pages-test FAIL the application info should succeed %Y%m%d_%H%M%S'
+ false
+fi
+
+RES=$(${gcmd} app update --app-id ${APPID} --approval-prog "${APPR_PROG}" --clear-prog "${SMALL_TEAL_FILE}" --from ${ACCOUNT} 2>&1 || true)
+EXP="Attempting to update app"
+if [[ $RES != *"${EXP}"* ]]; then
+ date '+app-extra-pages-test FAIL the application update should succeed %Y%m%d_%H%M%S'
+ false
+fi
+
+RES=$(${gcmd} app info --app-id ${APPID} 2>&1 || true)
+if [[ $RES == *"${PROGHASH}"* ]]; then
+ date '+app-extra-pages-test FAIL the application approval program should have been updated %Y%m%d_%H%M%S'
+ false
+fi
diff --git a/test/scripts/e2e_subs/serial/rest-proof-endpoint.sh b/test/scripts/e2e_subs/serial/rest-proof-endpoint.sh
index ba87561ef..d0faaee5d 100755
--- a/test/scripts/e2e_subs/serial/rest-proof-endpoint.sh
+++ b/test/scripts/e2e_subs/serial/rest-proof-endpoint.sh
@@ -17,9 +17,7 @@ while [[ "${NUM_TRANSACTIONS}" != "1" ]]; do
# check if the transaction was all alone in the round
call_and_verify "Checking block" "/v2/blocks/${ROUND}" 200 'txns'
- #TODO: The check with jq can be re-enabled after fixing JSONStrictHandle.
- #NUM_TRANSACTIONS=$(cat "${TEMPDIR}/curl_out.txt" | jq '.block.txns | length')
- NUM_TRANSACTIONS=$(cat "${TEMPDIR}/curl_out.txt" | grep type | wc -l | tr -d ' ')
+ NUM_TRANSACTIONS=$(cat "${TEMPDIR}/curl_out.txt" | jq '.block.txns | length')
done
call_and_verify "The proof should not be null." "/v2/blocks/${ROUND}/transactions/${TXID}/proof" 200 '"proof":""'
diff --git a/tools/network/dnssec/anchor_test.go b/tools/network/dnssec/anchor_test.go
index 810e2d9f4..f953f222c 100644
--- a/tools/network/dnssec/anchor_test.go
+++ b/tools/network/dnssec/anchor_test.go
@@ -19,10 +19,13 @@ package dnssec
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestParseRootTrustAnchor(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
an1, err := makeRootTrustAnchor(rootAnchorXML)
a.NoError(err)
diff --git a/tools/network/dnssec/client_test.go b/tools/network/dnssec/client_test.go
index 4cf6065e5..4d5e7e43f 100644
--- a/tools/network/dnssec/client_test.go
+++ b/tools/network/dnssec/client_test.go
@@ -21,11 +21,14 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/miekg/dns"
"github.com/stretchr/testify/require"
)
func TestEmptyClient(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
c := MakeDNSClient(nil, time.Second)
@@ -56,6 +59,8 @@ func (t ttr) queryServer(ctx context.Context, server ResolverAddress, msg *dns.M
}
func TestMockedClient(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
qs := ttr{}
diff --git a/tools/network/dnssec/config_test.go b/tools/network/dnssec/config_test.go
index c4a2279df..a0e9ebb0c 100644
--- a/tools/network/dnssec/config_test.go
+++ b/tools/network/dnssec/config_test.go
@@ -20,10 +20,13 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestConfigSystem(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
s, tm, err := SystemConfig()
a.NoError(err)
diff --git a/tools/network/dnssec/config_unix_test.go b/tools/network/dnssec/config_unix_test.go
index 402a1530a..f6ebe1bc1 100644
--- a/tools/network/dnssec/config_unix_test.go
+++ b/tools/network/dnssec/config_unix_test.go
@@ -23,10 +23,13 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestConfigEmpty(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
s, tm, err := systemConfig(nil)
@@ -48,6 +51,8 @@ func TestConfigEmpty(t *testing.T) {
}
func TestConfig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
b := bytes.NewBuffer([]byte("nameserver 127.0.0.1\n"))
diff --git a/tools/network/dnssec/dnssec_test.go b/tools/network/dnssec/dnssec_test.go
index c13d0e70f..612ae12b1 100644
--- a/tools/network/dnssec/dnssec_test.go
+++ b/tools/network/dnssec/dnssec_test.go
@@ -23,11 +23,14 @@ import (
"time"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/miekg/dns"
"github.com/stretchr/testify/require"
)
func TestLookup(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
r := makeEmptyTestResolver()
@@ -213,6 +216,8 @@ func TestLookup(t *testing.T) {
}
func TestLookupAux(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
r := makeEmptyTestResolver()
@@ -312,6 +317,8 @@ func TestLookupAux(t *testing.T) {
}
func TestDeadNS(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip() // skip real network tests in autotest
a := require.New(t)
@@ -329,6 +336,8 @@ func TestDeadNS(t *testing.T) {
}
func TestRealRequests(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip() // skip real network tests in autotest
a := require.New(t)
@@ -378,6 +387,8 @@ func TestRealRequests(t *testing.T) {
}
func TestDefaultResolver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
r := MakeDefaultDnssecResolver("127.0.0.1", logging.Base())
provided := len(DefaultDnssecAwareNSServers) + 1
diff --git a/tools/network/dnssec/sort_test.go b/tools/network/dnssec/sort_test.go
index cb6995d7d..523c7325d 100644
--- a/tools/network/dnssec/sort_test.go
+++ b/tools/network/dnssec/sort_test.go
@@ -20,10 +20,13 @@ import (
"net"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestSrvSort(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
arr := make([]*net.SRV, 0, 7)
diff --git a/tools/network/dnssec/trustedchain_test.go b/tools/network/dnssec/trustedchain_test.go
index 5a71b36e2..9c541299e 100644
--- a/tools/network/dnssec/trustedchain_test.go
+++ b/tools/network/dnssec/trustedchain_test.go
@@ -22,11 +22,14 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/miekg/dns"
"github.com/stretchr/testify/require"
)
func TestTrustChainBasic(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
r := makeTestResolver()
@@ -57,6 +60,8 @@ func TestTrustChainBasic(t *testing.T) {
}
func TestEnsureTrustChain(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var err error
@@ -270,6 +275,8 @@ func TestEnsureTrustChain(t *testing.T) {
}
func TestEnsureTrustChainFailures(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var err error
@@ -319,6 +326,8 @@ func TestEnsureTrustChainFailures(t *testing.T) {
}
func TestAuthenticate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var err error
@@ -376,6 +385,8 @@ func TestAuthenticate(t *testing.T) {
}
func TestQueryWrapper(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
r := makeEmptyTestResolver()
diff --git a/tools/network/dnssec/trustedzone_test.go b/tools/network/dnssec/trustedzone_test.go
index dfb17c90c..27759eee4 100644
--- a/tools/network/dnssec/trustedzone_test.go
+++ b/tools/network/dnssec/trustedzone_test.go
@@ -21,11 +21,14 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/miekg/dns"
"github.com/stretchr/testify/require"
)
func TestTrustedZone(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
zsk := make(map[uint16]dns.DNSKEY)
@@ -98,6 +101,8 @@ func TestTrustedZone(t *testing.T) {
}
func TestMakeTrustedZone(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
tt, _ := time.Parse(time.RFC3339, "2020-02-12T00:00:00Z")
@@ -188,6 +193,8 @@ func TestMakeTrustedZone(t *testing.T) {
a.Empty(tzTest)
}
func TestVerifyRRSig(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
tt, _ := time.Parse(time.RFC3339, "2020-02-12T00:00:00Z")
@@ -228,6 +235,8 @@ func TestVerifyRRSig(t *testing.T) {
}
func TestMatchKSKDigest(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
r := makeTestResolver()
diff --git a/tools/network/dnssec/util_test.go b/tools/network/dnssec/util_test.go
index 634882818..9f5ffa4c5 100644
--- a/tools/network/dnssec/util_test.go
+++ b/tools/network/dnssec/util_test.go
@@ -19,10 +19,13 @@ package dnssec
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestSplitZone(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var res []string
var err error
@@ -54,6 +57,8 @@ func TestSplitZone(t *testing.T) {
}
func TestParentZone(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
var res string
var err error
diff --git a/tools/network/resolveController_test.go b/tools/network/resolveController_test.go
index 7e2ea282f..c30d3287c 100644
--- a/tools/network/resolveController_test.go
+++ b/tools/network/resolveController_test.go
@@ -25,10 +25,13 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/tools/network/dnssec"
)
func TestSystemResolver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
log := logging.Base()
@@ -43,6 +46,8 @@ func TestSystemResolver(t *testing.T) {
}
func TestFallbackResolver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
log := logging.Base()
@@ -58,6 +63,8 @@ func TestFallbackResolver(t *testing.T) {
}
func TestDefaultResolver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
log := logging.Base()
@@ -73,6 +80,8 @@ func TestDefaultResolver(t *testing.T) {
}
func TestRealNamesWithResolver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Skip() // skip real network tests in autotest
a := require.New(t)
log := logging.Base()
diff --git a/tools/network/resolver_test.go b/tools/network/resolver_test.go
index 1cbd49ede..2021daa2c 100644
--- a/tools/network/resolver_test.go
+++ b/tools/network/resolver_test.go
@@ -22,10 +22,13 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestResolver(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// start with a resolver that has no specific DNS address defined.
// we want to make sure that it will go to the default DNS server ( 8.8.8.8 )
resolver := Resolver{}
diff --git a/tools/network/telemetryURIUpdateService_test.go b/tools/network/telemetryURIUpdateService_test.go
index 85899a058..b254d4157 100644
--- a/tools/network/telemetryURIUpdateService_test.go
+++ b/tools/network/telemetryURIUpdateService_test.go
@@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
type telemetryURIUpdaterTest struct {
@@ -58,6 +59,7 @@ func (t *telemetryURIUpdaterTest) add(protocol, bootstrap string, addrs []string
}
func TestTelemetryURILookup(t *testing.T) {
+ partitiontest.PartitionTest(t)
// trivial success case.
uriUpdater := makeTelemetryURIUpdaterTest(config.Devnet)
diff --git a/util/bloom/bloom_test.go b/util/bloom/bloom_test.go
index abf4ff5c4..2380b8d87 100644
--- a/util/bloom/bloom_test.go
+++ b/util/bloom/bloom_test.go
@@ -16,9 +16,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/algorand/go-algorand/crypto"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestBitset(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
f := New(1024, 4, 1234)
for i := uint32(0); i < 1024; i++ {
if f.test(i) {
@@ -32,6 +35,8 @@ func TestBitset(t *testing.T) {
}
func TestFilter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
f := New(1024, 4, 1234)
if f.Test([]byte("foo")) {
t.Fatalf("foo not expected")
@@ -43,6 +48,8 @@ func TestFilter(t *testing.T) {
}
func TestOptimal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numElementsCases := []int{2000, 20000, 200000}
fpRateCases := []float64{0.001, 0.00001, 0.0000001}
// increasing numFP can reduce error, but makes the tests take longer
@@ -113,6 +120,8 @@ func (f *Filter) estimateFalsePositiveRate(numAdded uint32, numFP int) float64 {
}
func TestOptimalSize(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// These are the parameters we use in the Alpenhorn paper.
numElements := 150000
numBits, numHashes := Optimal(numElements, 1e-10)
@@ -125,6 +134,8 @@ func TestOptimalSize(t *testing.T) {
}
func TestIncompressible(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
numElements := 150000
numBits, numHashes := Optimal(numElements, 1e-10)
filter := New(numBits, numHashes, 1234)
@@ -145,6 +156,8 @@ func TestIncompressible(t *testing.T) {
}
func TestMarshalJSON(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
filter := New(1000, 6, 1234)
filter.Set([]byte("hello"))
data, err := json.Marshal(filter)
@@ -185,6 +198,8 @@ func BenchmarkCreateLargeFilter(b *testing.B) {
}
func TestMaxHashes(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// These are the parameters we use in the Alpenhorn paper.
numElements := 150000
_, numHashes := Optimal(numElements, 1e-100)
@@ -222,6 +237,8 @@ func TestMaxHashes(t *testing.T) {
// unmarshaled data stream, we can still call Test safely. If the unmarshaling fails, that's ok.
// This test was implemented as an attempt to ensure that the data member is always non-empty.
func TestEmptyFilter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
blm := New(200, 16, 1234)
marshaled, _ := blm.MarshalBinary()
for i := 0; i < len(marshaled); i++ {
@@ -236,6 +253,8 @@ func TestEmptyFilter(t *testing.T) {
// TestBinaryMarshalLength tests various sizes of bloom filters and ensures that the encoded binary
// size is equal to the one reported by BinaryMarshalLength.
func TestBinaryMarshalLength(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
for _, elementCount := range []int{2, 16, 1024, 32768, 5101, 100237, 144539} {
for _, falsePositiveRate := range []float64{0.2, 0.1, 0.01, 0.001, 0.00001, 0.0000001} {
sizeBits, numHashes := Optimal(elementCount, falsePositiveRate)
@@ -251,6 +270,8 @@ func TestBinaryMarshalLength(t *testing.T) {
}
func TestBloomFilterMemoryConsumption(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Run("Set", func(t *testing.T) {
N := 1000000
sizeBits, numHashes := Optimal(N, 0.01)
@@ -354,6 +375,8 @@ func BenchmarkBloomFilterTest(b *testing.B) {
// TestBloomFilterReferenceHash ensure that we generate a bloom filter in a consistent way. This is important since we want to ensure that
// this code is backward compatible.
func TestBloomFilterReferenceHash(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
N := 3
sizeBits, numHashes := Optimal(N, 0.01)
prefix := uint32(0x11223344)
diff --git a/util/codecs/json_test.go b/util/codecs/json_test.go
index 61c3e2246..432784a48 100644
--- a/util/codecs/json_test.go
+++ b/util/codecs/json_test.go
@@ -17,6 +17,7 @@
package codecs
import (
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
"testing"
)
@@ -28,6 +29,8 @@ type testValue struct {
}
func TestIsDefaultValue(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
a := require.New(t)
v := testValue{
diff --git a/util/db/dbutil_test.go b/util/db/dbutil_test.go
index df523f63d..a675d3b84 100644
--- a/util/db/dbutil_test.go
+++ b/util/db/dbutil_test.go
@@ -33,9 +33,12 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/logging"
+ "github.com/algorand/go-algorand/test/partitiontest"
)
func TestInMemoryDisposal(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
acc, err := MakeAccessor("fn.db", false, true)
require.NoError(t, err)
err = acc.Atomic(func(ctx context.Context, tx *sql.Tx) error {
@@ -81,6 +84,8 @@ func TestInMemoryDisposal(t *testing.T) {
}
func TestInMemoryUniqueDB(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
acc, err := MakeAccessor("fn.db", false, true)
require.NoError(t, err)
defer acc.Close()
@@ -113,6 +118,8 @@ func TestInMemoryUniqueDB(t *testing.T) {
}
func TestDBConcurrency(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
fn := fmt.Sprintf("/tmp/%s.%d.sqlite3", t.Name(), crypto.RandUint64())
defer cleanupSqliteDb(t, fn)
@@ -229,6 +236,8 @@ func cleanupSqliteDb(t *testing.T, path string) {
}
func TestDBConcurrencyRW(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
dbFolder := "/dev/shm"
os := runtime.GOOS
if os == "darwin" {
@@ -351,6 +360,8 @@ func (wlc *WarningLogCounter) With(key string, value interface{}) logging.Logger
// Test resetting warning notification
func TestResettingTransactionWarnDeadline(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Run("expectedWarning", func(t *testing.T) {
t.Parallel()
acc, err := MakeAccessor("fn-expectedWarning.db", false, true)
@@ -388,6 +399,8 @@ func TestResettingTransactionWarnDeadline(t *testing.T) {
// Test the SetSynchronousMode function
func TestSetSynchronousMode(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
setSynchrounousModeHelper := func(mem bool, ctx context.Context, mode SynchronousMode, fullfsync bool) error {
acc, err := MakeAccessor("fn.db", false, mem)
require.NoError(t, err)
@@ -423,6 +436,8 @@ func TestSetSynchronousMode(t *testing.T) {
// it demonstrates that at any time before we're calling Commit, the database content can be read, and it's containing it's pre-transaction
// value.
func TestReadingWhileWriting(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
writeAcc, err := MakeAccessor("fn.db", false, false)
require.NoError(t, err)
defer os.Remove("fn.db")
diff --git a/util/db/versioning_test.go b/util/db/versioning_test.go
index d4083a2f6..29b96eb23 100644
--- a/util/db/versioning_test.go
+++ b/util/db/versioning_test.go
@@ -22,6 +22,7 @@ import (
"os"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -89,6 +90,8 @@ func testVersioning(t *testing.T, inMemory bool) {
}
func TestVersioning(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
t.Run("InMem", func(t *testing.T) { testVersioning(t, true) })
t.Run("OnDisk", func(t *testing.T) { testVersioning(t, false) })
}
diff --git a/util/metrics/counter_test.go b/util/metrics/counter_test.go
index 7ac853822..67c7a0785 100644
--- a/util/metrics/counter_test.go
+++ b/util/metrics/counter_test.go
@@ -22,6 +22,7 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -30,6 +31,7 @@ type CounterTest struct {
}
func TestMetricCounter(t *testing.T) {
+ partitiontest.PartitionTest(t)
test := &CounterTest{
MetricTest: NewMetricTest(),
@@ -75,6 +77,8 @@ func TestMetricCounter(t *testing.T) {
}
func TestMetricCounterFastInts(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
test := &CounterTest{
MetricTest: NewMetricTest(),
}
@@ -120,6 +124,8 @@ func TestMetricCounterFastInts(t *testing.T) {
}
func TestMetricCounterMixed(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
test := &CounterTest{
MetricTest: NewMetricTest(),
}
diff --git a/util/metrics/gauge.go b/util/metrics/gauge.go
index 025d84bd3..c1497489e 100644
--- a/util/metrics/gauge.go
+++ b/util/metrics/gauge.go
@@ -20,9 +20,25 @@ import (
"math"
"strconv"
"strings"
- "time"
+
+ "github.com/algorand/go-deadlock"
)
+// Gauge represent a single gauge variable.
+type Gauge struct {
+ deadlock.Mutex
+ name string
+ description string
+ labels map[string]int // map each label ( i.e. httpErrorCode ) to an index.
+ valuesIndices map[int]*gaugeValues // maps each set of labels into a concrete gauge
+}
+
+type gaugeValues struct {
+ gauge float64
+ labels map[string]string
+ formattedLabels string
+}
+
// MakeGauge create a new gauge with the provided name and description.
func MakeGauge(metric MetricName) *Gauge {
c := &Gauge{
@@ -35,15 +51,6 @@ func MakeGauge(metric MetricName) *Gauge {
return c
}
-// TouchAll updates all the timestamps associated with this metric.
-func (gauge *Gauge) TouchAll() {
- gauge.Lock()
- defer gauge.Unlock()
- for _, val := range gauge.valuesIndices {
- val.timestamp = time.Now()
- }
-}
-
// Register registers the gauge with the default/specific registry
func (gauge *Gauge) Register(reg *Registry) {
if reg == nil {
@@ -73,16 +80,14 @@ func (gauge *Gauge) Add(x float64, labels map[string]string) {
if gaugeObj, has := gauge.valuesIndices[labelIndex]; !has {
// we need to add a new gauge.
val := &gaugeValues{
- gauge: x,
- labels: labels,
- timestamp: time.Now(),
+ gauge: x,
+ labels: labels,
}
val.createFormattedLabel()
gauge.valuesIndices[labelIndex] = val
} else {
// update existing value.
gaugeObj.gauge += x
- gaugeObj.timestamp = time.Now()
}
}
@@ -97,16 +102,14 @@ func (gauge *Gauge) Set(x float64, labels map[string]string) {
if gaugeObj, has := gauge.valuesIndices[labelIndex]; !has {
// we need to add a new gauge.
val := &gaugeValues{
- gauge: x,
- labels: labels,
- timestamp: time.Now(),
+ gauge: x,
+ labels: labels,
}
val.createFormattedLabel()
gauge.valuesIndices[labelIndex] = val
} else {
// update existing value.
gaugeObj.gauge = x
- gaugeObj.timestamp = time.Now()
}
}
@@ -139,26 +142,11 @@ func (cv *gaugeValues) createFormattedLabel() {
cv.formattedLabels = buf.String()[1:]
}
-// filterExpiredMetrics scans the gauge.valuesIndices map and removing all the gauges that
-// haven't been updated in the past <maxMetricRetensionDuration> units of time.
-func (gauge *Gauge) filterExpiredMetrics() {
- // find out what the cut off date is
- metricRetensionThreshold := time.Now().Add(-maxMetricRetensionDuration)
-
- for gaugeKey, gaugeObj := range gauge.valuesIndices {
- if gaugeObj.timestamp.Before(metricRetensionThreshold) {
- delete(gauge.valuesIndices, gaugeKey)
- }
- }
-}
-
// WriteMetric writes the metric into the output stream
func (gauge *Gauge) WriteMetric(buf *strings.Builder, parentLabels string) {
gauge.Lock()
defer gauge.Unlock()
- gauge.filterExpiredMetrics()
-
if len(gauge.valuesIndices) < 1 {
return
}
@@ -190,8 +178,6 @@ func (gauge *Gauge) AddMetric(values map[string]string) {
gauge.Lock()
defer gauge.Unlock()
- gauge.filterExpiredMetrics()
-
if len(gauge.valuesIndices) < 1 {
return
}
diff --git a/util/metrics/gauge_test.go b/util/metrics/gauge_test.go
index 90111cf15..1e1164b01 100644
--- a/util/metrics/gauge_test.go
+++ b/util/metrics/gauge_test.go
@@ -23,6 +23,7 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -31,6 +32,7 @@ type GaugeTest struct {
}
func TestMetricGauge(t *testing.T) {
+ partitiontest.PartitionTest(t)
test := &GaugeTest{
MetricTest: NewMetricTest(),
diff --git a/util/metrics/registry_test.go b/util/metrics/registry_test.go
index 24c089fe1..e4d8fc2d7 100644
--- a/util/metrics/registry_test.go
+++ b/util/metrics/registry_test.go
@@ -22,10 +22,13 @@ import (
"strings"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestWriteAdd(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
// Test AddMetrics and WriteMetrics with a counter
counter := MakeCounter(MetricName{Name: "gauge-name", Description: "gauge description"})
counter.Add(12.34, nil)
diff --git a/util/metrics/reporter_test.go b/util/metrics/reporter_test.go
index bad050364..cec86f63e 100755
--- a/util/metrics/reporter_test.go
+++ b/util/metrics/reporter_test.go
@@ -19,10 +19,13 @@ package metrics
import (
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestParseNodeExporterArgs(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
passTestcases := map[string][]string{
"./node_exporter": {"./node_exporter", "--web.listen-address=:9100", "--web.telemetry-path=/metrics"}, // simple case
"./node_exporter --collector.systemd": {"./node_exporter", "--collector.systemd", "--web.listen-address=:9100", "--web.telemetry-path=/metrics"}, // extended case with one argument
diff --git a/util/metrics/segment_test.go b/util/metrics/segment_test.go
index 725bbb353..d3590f5a6 100644
--- a/util/metrics/segment_test.go
+++ b/util/metrics/segment_test.go
@@ -24,6 +24,7 @@ import (
"testing"
"time"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -32,6 +33,8 @@ type SegmentTest struct {
}
func TestMetricSegment(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const initialSleepDuration = 10 * time.Millisecond
const maxSleepDuration = 4 * time.Second
done := false
diff --git a/util/metrics/stringGauge_test.go b/util/metrics/stringGauge_test.go
index fca458f54..1ea3650bc 100644
--- a/util/metrics/stringGauge_test.go
+++ b/util/metrics/stringGauge_test.go
@@ -20,6 +20,7 @@ import (
"strings"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
@@ -29,6 +30,8 @@ func hasKey(data map[string]string, key string) bool {
}
func TestMetricStringGauge(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
stringGauge := MakeStringGauge()
stringGauge.Set("number-key", "1")
stringGauge.Set("string-key", "value")
diff --git a/util/metrics/tagcounter_test.go b/util/metrics/tagcounter_test.go
index 52d0cb349..1e1c5b5aa 100644
--- a/util/metrics/tagcounter_test.go
+++ b/util/metrics/tagcounter_test.go
@@ -22,10 +22,13 @@ import (
"sync"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestTagCounter(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
tags := make([]string, 17)
for i := range tags {
tags[i] = fmt.Sprintf("A%c", 'A'+i)
diff --git a/util/s3/s3Helper_test.go b/util/s3/s3Helper_test.go
index 8defa9f42..20406e733 100644
--- a/util/s3/s3Helper_test.go
+++ b/util/s3/s3Helper_test.go
@@ -21,10 +21,13 @@ import (
"reflect"
"testing"
+ "github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)
func TestGetS3UploadBucket(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
tests := []struct {
name string
getDefault bool
@@ -50,6 +53,8 @@ func TestGetS3UploadBucket(t *testing.T) {
}
func TestGetS3ReleaseBucket(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
tests := []struct {
name string
getDefault bool
@@ -75,6 +80,8 @@ func TestGetS3ReleaseBucket(t *testing.T) {
}
func Test_getS3Region(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
tests := []struct {
name string
getDefault bool
@@ -100,6 +107,8 @@ func Test_getS3Region(t *testing.T) {
}
func TestMakeS3SessionForUploadWithBucket(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const bucket1 = "test-bucket"
const publicUploadBucket = "algorand-uploads"
const emptyBucket = ""
@@ -142,6 +151,8 @@ func TestMakeS3SessionForUploadWithBucket(t *testing.T) {
}
func TestMakeS3SessionForDownloadWithBucket(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
const bucket1 = "test-bucket"
const publicReleaseBucket = "algorand-releases"
const emptyBucket = ""
@@ -184,6 +195,8 @@ func TestMakeS3SessionForDownloadWithBucket(t *testing.T) {
}
func TestGetVersionFromName(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type args struct {
name string
version string
@@ -206,6 +219,8 @@ func TestGetVersionFromName(t *testing.T) {
}
func TestGetPartsFromVersion(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
type args struct {
name string
version uint64
diff --git a/util/timers/monotonic_test.go b/util/timers/monotonic_test.go
index 5c0026650..115c70295 100644
--- a/util/timers/monotonic_test.go
+++ b/util/timers/monotonic_test.go
@@ -17,6 +17,7 @@
package timers
import (
+ "github.com/algorand/go-algorand/test/partitiontest"
"math/rand"
"testing"
"time"
@@ -32,6 +33,8 @@ func polled(ch <-chan time.Time) bool {
}
func TestMonotonicDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var m Monotonic
var c Clock
var ch <-chan time.Time
@@ -56,6 +59,8 @@ func TestMonotonicDelta(t *testing.T) {
}
func TestMonotonicZeroDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var m Monotonic
var c Clock
var ch <-chan time.Time
@@ -68,6 +73,8 @@ func TestMonotonicZeroDelta(t *testing.T) {
}
func TestMonotonicNegativeDelta(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var m Monotonic
var c Clock
var ch <-chan time.Time
@@ -80,6 +87,8 @@ func TestMonotonicNegativeDelta(t *testing.T) {
}
func TestMonotonicZeroTwice(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
var m Monotonic
var c Clock
var ch <-chan time.Time
@@ -110,6 +119,8 @@ func TestMonotonicZeroTwice(t *testing.T) {
}
func TestMonotonicEncodeDecode(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
singleTest := func(c Clock, descr string) {
data := c.Encode()
c0, err := c.Decode(data)