Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add smaller test and debug improvements #1585

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/actions/iota-rebase-sandbox/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
description: "Platform to download binary for (linux or macos)"
required: true
default: "linux"
logfile:
description: "Optional log file to store server log as workflow artifact"
required: false
default: ""

runs:
using: composite
Expand Down Expand Up @@ -49,5 +53,10 @@ runs:
run: |
# Clear previous configuration
rm -rf ~/.iota || true

# Check log file arg
LOGFILE="${{ inputs.logfile }}"
echo "Starting server with log file: $LOGFILE"

# Start the network
iota start --with-faucet &
iota start --with-faucet ${{ inputs.logfile && format('> {0} 2>&1', inputs.logfile) || '' }} &
22 changes: 22 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ jobs:
env:
SCCACHE_DIR: ${{ matrix.sccache-path }}
RUSTC_WRAPPER: sccache
IOTA_SERVER_LOGFILE: >-
${{
matrix.os != 'windows-latest' &&
format(
'iota-server-logs-build-and-test-{0}-{1}-{2}-{3}.log',
matrix.os == 'ubuntu-24.04' && 'linux' || 'macos',
github.run_id,
github.run_number,
github.run_attempt
) ||
''
}}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -135,6 +147,7 @@ jobs:
uses: './.github/actions/iota-rebase-sandbox/setup'
with:
platform: ${{ matrix.os == 'ubuntu-24.04' && 'linux' || 'macos' }}
logfile: ${{ env.IOTA_SERVER_LOGFILE }}

- name: test IotaIdentity package
if: matrix.os != 'windows-latest'
Expand Down Expand Up @@ -174,6 +187,15 @@ jobs:
npm ci
npm run test:readme:rust

- name: Archive server logs
if: ${{ env.IOTA_SERVER_LOGFILE }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.IOTA_SERVER_LOGFILE }}
path: iota/${{ env.IOTA_SERVER_LOGFILE }}
if-no-files-found: error
retention-days: 1

- name: Stop sccache
uses: './.github/actions/rust/sccache/stop-sccache'
with:
Expand Down
17 changes: 8 additions & 9 deletions bindings/grpc/tests/api/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,19 @@ async fn publish_package(active_address: IotaAddress) -> anyhow::Result<ObjectID
.arg("publish_identity_package.sh")
.output()
.await?;
let stdout = std::str::from_utf8(&output.stdout).unwrap();

if !output.status.success() {
anyhow::bail!(
"Failed to publish move package: \n\n{}\n\n{}",
std::str::from_utf8(&output.stdout).unwrap(),
std::str::from_utf8(&output.stderr).unwrap()
);
let stderr = std::str::from_utf8(&output.stderr).unwrap();
anyhow::bail!("Failed to publish move package: \n\n{stdout}\n\n{stderr}");
}

let package_id: ObjectID = {
let output_str = std::str::from_utf8(&output.stdout).unwrap().trim();
ObjectID::from_str(output_str).context(format!(
"failed to find IDENTITY_IOTA_PKG_ID in response from: {output_str}"
))?
let stdout_trimmed = stdout.trim();
ObjectID::from_str(stdout_trimmed).with_context(|| {
let stderr = std::str::from_utf8(&output.stderr).unwrap();
format!("failed to find IDENTITY_IOTA_PKG_ID in response from: '{stdout_trimmed}'; {stderr}")
})?
};

// Persist package ID in order to avoid publishing the package for every test.
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/identity_wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit",
"cypress": "cypress open",
"fmt": "dprint fmt",
"fix_docs": "find ./docs/wasm/ -type f -name '*.md' -exec sed -Ei 's/(\\.md?#([^#]*)?)#/\\1/' {} +"
"fix_docs": "find ./docs/wasm/ -type f -name '*.md' -exec sed -E -i.bak -e 's/(\\.md?#([^#]*)?)#/\\1/' {} ';' -exec rm {}.bak ';'"
},
"config": {
"CYPRESS_VERIFY_TIMEOUT": 100000
Expand Down
10 changes: 8 additions & 2 deletions identity_iota_core/scripts/publish_identity_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ script_dir=$(cd "$(dirname $0)" && pwd)
package_dir=$script_dir/../packages/iota_identity

# echo "publishing package from $package_dir"
package_id=$(iota client publish --with-unpublished-dependencies --skip-dependency-verification --silence-warnings --json --gas-budget 500000000 $package_dir | jq --raw-output '.objectChanges[] | select(.type | contains("published")) | .packageId')
export IOTA_IDENTITY_PKG_ID=$package_id
RESPONSE=$(iota client publish --with-unpublished-dependencies --skip-dependency-verification --silence-warnings --json --gas-budget 500000000 $package_dir)
{ # try
PACKAGE_ID=$(echo $RESPONSE | jq --raw-output '.objectChanges[] | select(.type | contains("published")) | .packageId')
} || { # catch
echo $RESPONSE
}

export IOTA_IDENTITY_PKG_ID=$PACKAGE_ID
echo "${IOTA_IDENTITY_PKG_ID}"
28 changes: 14 additions & 14 deletions identity_iota_core/tests/e2e/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,19 @@ async fn publish_package(active_address: IotaAddress) -> anyhow::Result<ObjectID
.arg("publish_identity_package.sh")
.output()
.await?;
let stdout = std::str::from_utf8(&output.stdout).unwrap();

if !output.status.success() {
anyhow::bail!(
"Failed to publish move package: \n\n{}\n\n{}",
std::str::from_utf8(&output.stdout).unwrap(),
std::str::from_utf8(&output.stderr).unwrap()
);
let stderr = std::str::from_utf8(&output.stderr).unwrap();
anyhow::bail!("Failed to publish move package: \n\n{stdout}\n\n{stderr}");
}

let package_id: ObjectID = {
let output_str = std::str::from_utf8(&output.stdout).unwrap().trim();
ObjectID::from_str(output_str).context(format!(
"failed to find IDENTITY_IOTA_PKG_ID in response from: {output_str}"
))?
let stdout_trimmed = stdout.trim();
ObjectID::from_str(stdout_trimmed).with_context(|| {
let stderr = std::str::from_utf8(&output.stderr).unwrap();
format!("failed to find IDENTITY_IOTA_PKG_ID in response from: '{stdout_trimmed}'; {stderr}")
})?
};

// Persist package ID in order to avoid publishing the package for every test.
Expand Down Expand Up @@ -349,11 +348,12 @@ pub async fn make_address(key_type: SignatureScheme) -> anyhow::Result<IotaAddre
.output()
.await?;
let new_address = {
let output_str = std::str::from_utf8(&output.stdout).unwrap();
let start_of_json = output_str
.find('{')
.ok_or(anyhow!("No json in output: {}", output_str))?;
let json_result = serde_json::from_str::<Value>(output_str[start_of_json..].trim())?;
let stdout = std::str::from_utf8(&output.stdout).unwrap();
let start_of_json = stdout.find('{').ok_or_else(|| {
let stderr = std::str::from_utf8(&output.stderr).unwrap();
anyhow!("No json in output: '{stdout}'; {stderr}",)
})?;
let json_result = serde_json::from_str::<Value>(stdout[start_of_json..].trim())?;
let address_str = json_result
.get("address")
.context("no address in JSON output")?
Expand Down