Decide and test what entering a second time does

Aperta
#2 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
blockchain

Direzione di ricerca

Start in enter in src/lib.rs, which writes DataKey::Member(subject) and publishes Entered without checking for an existing member, then read src/test.rs to see what is covered. Choose one repeat-entry behaviour, either keeping it or making it a no-op, and decide whether the stored ledger sequence is exposed through a getter or removed. Done means tests for the double entry and the first Entered event (topics, subject, policy_version) pass under cargo test --locked, the README states the behaviour in one sentence, and the WASM size from stellar contract build --locked is reported.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement help wanted

Written against commit a23a8df; later commits may have moved things, so check the code first.

Size: Trivial

Description
Nothing says what happens when an address that is already a member enters again, and no test checks it. Today the second entry
is accepted, overwrites the stored record, and publishes a second Entered event. The value it overwrites is never read.

Current state
enter in src/lib.rs always runs persistent().set(&DataKey::Member(subject), &env.ledger().sequence()), extends the
lifetimes, and publishes Entered { subject, policy_version }. It never looks to see whether the address is already a member.
is_member only calls has, and no function returns the stored ledger sequence, so the value written is dead data.
src/test.rs has no test that enters twice, and none that looks at the events (env.events()), so the event's topics and
policy_version field are unchecked too.

What to build
Pick one behaviour for a repeat entry and make it explicit:

  • keep it (a repeat entry succeeds, refreshes the record and emits another event) and say so in the README and a doc comment, or
  • make it a no-op for an existing member, with no second event.

Either way, decide what the stored value is for: expose it (for example a member_since getter) or store something that does not
pretend to carry information. Then test the behaviour, and test the event once: its topics (gate, entered), the subject and
the policy_version taken from the decision.

Acceptance criteria

  • A test for entering twice that asserts the chosen behaviour, including how many events were published.
  • A test that the first entry publishes Entered with the right topics, subject and policy version.
  • The stored value is either readable through the contract's interface or removed.
  • The README says what a repeat entry does, in one sentence.
  • The gate's WASM stays small; say what size it is now.

Out of scope
Revoking membership. Counting entries.

Verification
cargo test --locked, and stellar contract build --locked for the size.

Lingua principale
Rust
Stelle
2
Fork
2
Merge medio
2h 30m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Sorogate/example-consumer

Tutte le issue di Sorogate/example-consumer

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.