MCPcopy Create free account
hub / github.com/erpc/erpc / TestCounterInt64_SetValueUpdatesLastUpdated

Function TestCounterInt64_SetValueUpdatesLastUpdated

data/shared_state_variable_test.go:602–619  ·  view source on GitHub ↗

Test that calling setValue directly (as done by remote update watchers or initial value fetch) refreshes the internal lastUpdated timestamp so that subsequent IsStale checks reflect the recent update.

(t *testing.T)

Source from the content-addressed store, hash-verified

600// Test that calling setValue directly (as done by remote update watchers or initial value fetch) refreshes the
601// internal lastUpdated timestamp so that subsequent IsStale checks reflect the recent update.
602func TestCounterInt64_SetValueUpdatesLastUpdated(t *testing.T) {
603 counter := &counterInt64{
604 ignoreRollbackOf: 1024,
605 registry: &sharedStateRegistry{
606 logger: &log.Logger,
607 },
608 }
609
610 // Simulate a write originating from the remote sync by calling setValue directly.
611 counter.processNewValue(UpdateSourceTest, 123)
612
613 // Immediately after the write the counter must not be considered stale for any reasonable staleness window.
614 assert.False(t, counter.IsStale(time.Second), "counter should not be stale right after setValue call")
615
616 // After advancing the clock beyond the staleness window the value should be considered stale.
617 time.Sleep(15 * time.Millisecond)
618 assert.True(t, counter.IsStale(10*time.Millisecond), "counter should become stale once the window elapses")
619}
620
621func TestCounterInt64_TryUpdate_RollbackLogic(t *testing.T) {
622 tests := []struct {

Callers

nothing calls this directly

Calls 2

processNewValueMethod · 0.95
IsStaleMethod · 0.65

Tested by

no test coverage detected