From f589555701bcdb4a0f2f5b8892f49b05a8d381fb Mon Sep 17 00:00:00 2001 From: Sergey Gorbunov Date: Tue, 28 Jan 2025 18:59:59 +0300 Subject: [PATCH] Fix more tests, 53 still failing --- test/sharness/actual | 148 ++++++++++++++++++++++++++++++++++ test/sharness/t0021-config.sh | 63 +++++++-------- 2 files changed, 177 insertions(+), 34 deletions(-) create mode 100644 test/sharness/actual diff --git a/test/sharness/actual b/test/sharness/actual new file mode 100644 index 00000000000..9d5fa017580 --- /dev/null +++ b/test/sharness/actual @@ -0,0 +1,148 @@ +{ + "API": { + "HTTPHeaders": {} + }, + "Addresses": { + "API": "/ip4/127.0.0.1/tcp/5001", + "Announce": [], + "AppendAnnounce": [], + "Gateway": "/ip4/127.0.0.1/tcp/8080", + "NoAnnounce": [], + "Swarm": [ + "/ip4/0.0.0.0/tcp/4001", + "/ip6/::/tcp/4001", + "/ip4/0.0.0.0/udp/4001/webrtc-direct", + "/ip4/0.0.0.0/udp/4001/quic-v1", + "/ip4/0.0.0.0/udp/4001/quic-v1/webtransport", + "/ip6/::/udp/4001/webrtc-direct", + "/ip6/::/udp/4001/quic-v1", + "/ip6/::/udp/4001/quic-v1/webtransport" + ] + }, + "AutoNAT": {}, + "AutoTLS": {}, + "Bootstrap": null, + "DNS": { + "Resolvers": {} + }, + "Datastore": { + "BlockKeyCacheSize": null, + "BloomFilterSize": 0, + "GCPeriod": "1h", + "HashOnRead": false, + "Spec": { + "mounts": [ + { + "child": { + "path": "blocks", + "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2", + "sync": false, + "type": "flatfs" + }, + "mountpoint": "/blocks", + "prefix": "flatfs.datastore", + "type": "measure" + }, + { + "child": { + "compression": "none", + "path": "datastore", + "type": "levelds" + }, + "mountpoint": "/", + "prefix": "leveldb.datastore", + "type": "measure" + } + ], + "type": "mount" + }, + "StorageGCWatermark": 90, + "StorageMax": "10GB" + }, + "Discovery": { + "MDNS": { + "Enabled": true + } + }, + "Experimental": { + "FilestoreEnabled": false, + "Libp2pStreamMounting": false, + "OptimisticProvide": false, + "OptimisticProvideJobsPoolSize": 0, + "P2pHttpProxy": false, + "StrategicProviding": false, + "UrlstoreEnabled": false + }, + "Gateway": { + "DeserializedResponses": null, + "DisableHTMLErrors": null, + "ExposeRoutingAPI": null, + "HTTPHeaders": {}, + "NoDNSLink": false, + "NoFetch": false, + "PublicGateways": null, + "RootRedirect": "" + }, + "Identity": { + "PeerID": "12D3KooWKr2Z9EN4jg1kzxzb8dtn21U7HFMEU1SCPawMavyH1vhR" + }, + "Import": { + "BatchMaxNodes": null, + "BatchMaxSize": null, + "CidVersion": null, + "HashFunction": null, + "UnixFSChunker": null, + "UnixFSRawLeaves": null + }, + "Internal": {}, + "Ipns": { + "RecordLifetime": "", + "RepublishPeriod": "", + "ResolveCacheSize": 128 + }, + "Migration": { + "DownloadSources": [], + "Keep": "" + }, + "Mounts": { + "FuseAllowOther": false, + "IPFS": "/ipfs", + "IPNS": "/ipns" + }, + "Peering": { + "Peers": null + }, + "Pinning": { + "RemoteServices": {} + }, + "Plugins": { + "Plugins": null + }, + "Provider": { + "Strategy": "" + }, + "Pubsub": { + "DisableSigning": false, + "Router": "" + }, + "Reprovider": {}, + "Routing": { + "Methods": null, + "Routers": null + }, + "Swarm": { + "AddrFilters": null, + "ConnMgr": {}, + "DisableBandwidthMetrics": false, + "DisableNatPortMap": false, + "RelayClient": {}, + "RelayService": {}, + "ResourceMgr": {}, + "Transports": { + "Multiplexers": {}, + "Network": {}, + "Security": {} + } + }, + "Version": {} +} diff --git a/test/sharness/t0021-config.sh b/test/sharness/t0021-config.sh index 95a8a7d8746..fe44ed1905a 100755 --- a/test/sharness/t0021-config.sh +++ b/test/sharness/t0021-config.sh @@ -13,27 +13,27 @@ test_config_cmd_set() { cfg_key=$1 cfg_val=$2 - test_expect_success "ipfs config succeeds" ' - ipfs config $cfg_flags "$cfg_key" "$cfg_val" - ' + test_expect_success "ipfs config succeeds" " + ipfs config $cfg_flags \"$cfg_key\" \"$cfg_val\" + " - test_expect_success "ipfs config output looks good" ' - echo "$cfg_val" >expected && - ipfs config "$cfg_key" >actual && + test_expect_success "ipfs config output looks good" " + echo \"$cfg_val\" >expected && + ipfs config \"$cfg_key\" >actual && test_cmp expected actual - ' + " # also test our lib function. it should work too. cfg_key="Lib.$cfg_key" - test_expect_success "test_config_set succeeds" ' - test_config_set $cfg_flags "$cfg_key" "$cfg_val" - ' + test_expect_success "test_config_set succeeds" " + test_config_set $cfg_flags \"$cfg_key\" \"$cfg_val\" + " - test_expect_success "test_config_set value looks good" ' - echo "$cfg_val" >expected && - ipfs config "$cfg_key" >actual && + test_expect_success "test_config_set value looks good" " + echo \"$cfg_val\" >expected && + ipfs config \"$cfg_key\" >actual && test_cmp expected actual - ' + " } # this is a bit brittle. the problem is we need to test @@ -41,12 +41,7 @@ test_config_cmd_set() { # (i.e. just setting 'ipfs config --json foo "[1, 2, 3]"') may # set it as astring instead of proper json. We leverage the # unmarshalling that has to happen. -CONFIG_SET_JSON_TEST='{ - "MDNS": { - "Enabled": true, - "Interval": 10 - } -}' +CONFIG_SET_JSON_TEST='{"MDNS":{"Enabled":true}}' test_profile_apply_revert() { profile=$1 @@ -87,27 +82,27 @@ test_profile_apply_dry_run_not_alter() { } test_config_cmd() { - test_config_cmd_set "beep" "boop" - test_config_cmd_set "beep1" "boop2" - test_config_cmd_set "beep1" "boop2" - test_config_cmd_set "--bool" "beep2" "true" - test_config_cmd_set "--bool" "beep2" "false" - test_config_cmd_set "--json" "beep3" "true" - test_config_cmd_set "--json" "beep3" "false" + test_config_cmd_set "Addresses.API" "foo" + test_config_cmd_set "Addresses.Gateway" "bar" + test_config_cmd_set "Datastore.GCPeriod" "baz" + test_config_cmd_set "--bool" "Discovery.MDNS.Enabled" "true" + test_config_cmd_set "--bool" "Discovery.MDNS.Enabled" "false" + test_config_cmd_set "--json" "Datastore.HashOnRead" "true" + test_config_cmd_set "--json" "Datastore.HashOnRead" "false" test_config_cmd_set "--json" "Discovery" "$CONFIG_SET_JSON_TEST" - test_config_cmd_set "--json" "deep-not-defined.prop" "true" - test_config_cmd_set "--json" "deep-null" "null" - test_config_cmd_set "--json" "deep-null.prop" "true" + test_config_cmd_set "--json" "Experimental.FilestoreEnabled" "true" + test_config_cmd_set "--json" "Import.BatchMaxSize" "null" + test_config_cmd_set "--json" "Datastore.Spec" "true" test_expect_success "'ipfs config show' works" ' ipfs config show >actual ' test_expect_success "'ipfs config show' output looks good" ' - grep "\"beep\": \"boop\"," actual && - grep "\"beep1\": \"boop2\"," actual && - grep "\"beep2\": false," actual && - grep "\"beep3\": false," actual + grep "\"API\": \"foo\"," actual && + grep "\"Gateway\": \"bar\"" actual && + grep "\"Enabled\": false" actual && + grep "\"HashOnRead\": false" actual ' test_expect_success "'ipfs config show --config-file' works" '