test(agentcompat): add exact stress scenario

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
naiba
2026-07-20 04:54:03 +00:00
co-authored by naiba/CloudCode
parent 64daa6e9ae
commit d501f23473
24 changed files with 2784 additions and 0 deletions
@@ -0,0 +1,35 @@
//go:build linux && agentcompat
package scenario
import (
"crypto/sha256"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestStressPathLockProofRequiresExactStripeCount(t *testing.T) {
for _, stripes := range []int{1023, 1025} {
require.ErrorIs(t, (stressPathLockProof{Stripes: stripes}).Validate(), ErrStressPathLockProof)
}
require.NoError(t, (stressPathLockProof{Stripes: 1024}).Validate())
}
func TestStressPathLockProofDoesNotModifyAgentSource(t *testing.T) {
sourceDir := os.Getenv("AGENTCOMPAT_AGENT_SOURCE")
if sourceDir == "" {
t.Skip("AGENTCOMPAT_AGENT_SOURCE is not configured")
}
path := sourceDir + "/cmd/agent/mcp_fs_path_lock.go"
before, err := os.ReadFile(path)
require.NoError(t, err)
beforeHash := sha256.Sum256(before)
proof, err := proveStressPathLockStripes(t.Context(), sourceDir)
require.NoError(t, err)
require.NoError(t, proof.Validate())
after, err := os.ReadFile(path)
require.NoError(t, err)
require.Equal(t, beforeHash, sha256.Sum256(after))
}