-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_tests.py
More file actions
62 lines (53 loc) · 1.96 KB
/
Copy pathfix_tests.py
File metadata and controls
62 lines (53 loc) · 1.96 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
61
62
import os
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"
]
for file_path in files:
with open(file_path, "r") as f:
content = f.read()
# Add import
if 'github.com/cosmos/cosmos-sdk/codec/address' not in content:
content = content.replace(
'\t"github.com/cosmos/cosmos-sdk/codec"',
'\t"github.com/cosmos/cosmos-sdk/codec"\n\t"github.com/cosmos/cosmos-sdk/codec/address"'
)
# Remove banktypes.TransientKey usage
content = content.replace(
'\t// Create transient store keys\n\ttKeys := storetypes.NewTransientStoreKeys(banktypes.TransientKey)\n\n',
''
)
content = content.replace(
'\tfor _, tKey := range tKeys {\n\t\tstateStore.MountStoreWithDB(tKey, storetypes.StoreTypeTransient, db)\n\t}\n',
''
)
# Remove usage in DefaultContextWithDB
content = content.replace(
'testutil.DefaultContextWithDB(s.T(), storeKeys[authtypes.StoreKey], tKeys[banktypes.TransientKey])',
'testutil.DefaultContextWithDB(s.T(), storeKeys[authtypes.StoreKey], storetypes.NewTransientStoreKey("transient_test"))'
)
# Update authkeeper.NewAccountKeeper
# We need to inject the address codec.
old_call = """s.accountKeeper = authkeeper.NewAccountKeeper(
s.cdc,
runtime.NewKVStoreService(storeKeys[authtypes.StoreKey]),
authtypes.ProtoBaseAccount,
maccPerms,
"stateset",
s.authority.String(),
)"""
new_call = """s.accountKeeper = authkeeper.NewAccountKeeper(
s.cdc,
runtime.NewKVStoreService(storeKeys[authtypes.StoreKey]),
authtypes.ProtoBaseAccount,
maccPerms,
address.NewBech32Codec("stateset"),
"stateset",
s.authority.String(),
)"""
content = content.replace(old_call, new_call)
with open(file_path, "w") as f:
f.write(content)
print("Files updated.")