mesh/delivery-group group feat/a-counter-by-compare-and-set checking: 0 of 2 member(s) ready
mesh/merge-gate pass: builds mesh-tools, node-tools → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without (4 of …
mesh/repo-check pass: THE CHANGE ALTERS ITS OWN CHECK (merge-check.sh): main's version judged it; the change's judges the pull requests after it merges; it…
mesh/delivery superseded: a newer head of the same pull request
The issues module will hand out numbers through mesh/state.create and update. Two writers incrementing one counter a thousand times each through the module's bus now end at two thousand with every number handed out once; a stale, zero or future revision is refused with the lost-write code and writes nothing; a deleted key can be created again; and the lost-write code reaches a bundle wrapped or not, and no other refusal carries it. Both runtime tests run in the check's bundleless list, so mesh/repo-check runs them. Part of the issue tracker decision, hq research 042.
31 lines
1007 B
Go
31 lines
1007 B
Go
package launch
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
type lostWrite struct{}
|
|
|
|
func (lostWrite) Error() string {
|
|
return "issues.numbers.issue: the key was written by another writer first"
|
|
}
|
|
func (lostWrite) ErrorCode() int { return CodeChanged }
|
|
|
|
// A lost compare-and-set is answered to a bundle with its own code, wrapped or not, and the SDK tells it by
|
|
// that code alone (mesh-sdk's stdio.CodeChanged); every other refusal is the general code, never that one.
|
|
func TestALostWriteIsAnsweredWithItsOwnCodeAndNothingElseIs(t *testing.T) {
|
|
if CodeChanged != -32010 {
|
|
t.Fatalf("the lost-write code is %d; mesh-sdk tells it by -32010", CodeChanged)
|
|
}
|
|
for _, err := range []error{lostWrite{}, fmt.Errorf("asked by issues: %w", lostWrite{})} {
|
|
if got := errorCode(err); got != CodeChanged {
|
|
t.Errorf("%v is answered %d", err, got)
|
|
}
|
|
}
|
|
if got := errorCode(errors.New("issues keeps no state numbers")); got == CodeChanged || got != -32000 {
|
|
t.Errorf("a plain refusal is answered %d", got)
|
|
}
|
|
}
|