Skip to content

Increase Smart Contract Test Coverage - #769

Open
CollinsC1O wants to merge 3 commits into
Core-Foundry:mainfrom
CollinsC1O:test-coverage
Open

Increase Smart Contract Test Coverage #769
CollinsC1O wants to merge 3 commits into
Core-Foundry:mainfrom
CollinsC1O:test-coverage

Conversation

@CollinsC1O

Copy link
Copy Markdown
Contributor

Closes #403

Collins C Augustine and others added 3 commits August 30, 2026 20:14
… coverage (Core-Foundry#403)

The contract crate no longer compiled: botched merge-conflict resolutions
left duplicate definitions across errors.rs, events.rs, autoshare_logic.rs
and reputation.rs, and lib.rs had duplicate / mis-pathed test modules with
~25 suites disabled.

- errors.rs: dedupe the Error enum (unique discriminants 1..40)
- events.rs: remove duplicate event structs and a doubled #[contractevent]
- autoshare_logic.rs: drop the duplicated emit_batch_completed signature,
  the duplicated import block and a duplicate struct field
- lib.rs: collapse the three conflicting test-module blocks into one,
  re-expose the channel-subscription methods on #[contractimpl]
- re-enable every test suite and update stale call sites for the current
  API (schedule_notification / batch_schedule_notifications take a
  priority), TryFromVal imports, removed a benchmark using the deleted
  Budget::get_cpu_instruction_cost, fixed a wrong event-topic index and
  bad "name too long" test data; access_control_test stays excluded

Contract behaviour changes:
- record_delivery_attempt / _failure / _acknowledgment now reject unknown,
  revoked or expired notifications
- reduce_usage takes an explicit caller: Address
- calculate_reputation_score uses integer math spanning the full 0..100

New tests: edge_case_coverage_test.rs adds 34 failure-scenario / boundary
tests. Full suite: 445 passing, 0 failing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ear warnings

- add tests/reputation_test.rs (12 contract-level reputation tests) that
  previously lived only on the stale remote branch; ported to the current
  client API (record_delivery_success)
- revocation_test: add the missing #[test] on
  test_revoke_notification_while_contract_paused_fails so it actually runs
- clear compiler warnings across the re-enabled suites: drop unused imports,
  remove dead helper fns (topics_of / data_of), replace deprecated
  String::from_slice with String::from_str in metadata_validation, elide
  lifetimes in access_log_test / schema_version_test setup helpers
- scope the test-only Env import inside base::reputation::tests

Full suite: 458 passing, 0 failing, 0 warnings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase Smart Contract Test Coverage

1 participant