-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_setup_manual.py
More file actions
60 lines (47 loc) · 1.95 KB
/
Copy pathfix_setup_manual.py
File metadata and controls
60 lines (47 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import re
files = [
"tests/integration/ecommerce_flow_test.go",
"tests/integration/ai_agent_transaction_test.go",
"tests/integration/circuit_breaker_test.go",
"tests/integration/cross_module_compliance_test.go",
"tests/integration/stablecoin_lifecycle_test.go"
]
for file_path in files:
if not os.path.exists(file_path):
continue
with open(file_path, "r") as f:
content = f.read()
# We need to find where store creation starts
# It starts with `// Create multistore`
# And ends with `WithBlockTime(time.Now())`
start_marker = "// Create multistore"
end_marker = "WithBlockTime(time.Now())"
if start_marker in content and end_marker in content:
# Extract keys first just in case, though they are defined before this block
# storeKeys definition is before `// Create multistore`.
# New block to insert
new_block = """// Create multistore
db := dbm.NewMemDB()
cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
for _, key := range storeKeys {
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
}
transientKey := storetypes.NewTransientStoreKey("transient_test")
cms.MountStoreWithDB(transientKey, storetypes.StoreTypeTransient, db)
err := cms.LoadLatestVersion()
require.NoError(s.T(), err)
// Create context
s.ctx = sdk.NewContext(cms, false, log.NewNopLogger()).
WithBlockHeight(1).
WithBlockTime(time.Now())"""
# Regex to replace from start_marker to end_marker
pattern = re.escape(start_marker) + r'.*?' + re.escape(end_marker)
# Check if replacement works (handling newlines)
# re.DOTALL is needed
content = re.sub(pattern, new_block, content, flags=re.DOTALL)
with open(file_path, "w") as f:
f.write(content)
print(f"Updated {file_path}")
else:
print(f"Markers not found in {file_path}")