@@ -49,40 +49,29 @@ def entries():
49
49
50
50
51
51
@pytest .fixture
52
- def mapping_key ():
53
- return SolanaPublicKey ("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J" )
54
-
55
-
56
- def test_mapping_account_upate_from (
57
- solana_client , mapping_key , mapping_account_bytes , entries
58
- ):
59
- account = PythMappingAccount (
60
- key = mapping_key ,
52
+ def mapping_account (solana_client ):
53
+ return PythMappingAccount (
54
+ key = SolanaPublicKey ("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J" ),
61
55
solana = solana_client ,
62
56
)
63
- assert account .entries == []
64
- assert account .next_account_key is None
65
57
66
- account .update_from (
58
+
59
+ def test_mapping_account_update_from (
60
+ solana_client , mapping_account , mapping_account_bytes , entries
61
+ ):
62
+ mapping_account .update_from (
67
63
buffer = mapping_account_bytes ,
68
64
version = _VERSION_2 ,
69
65
offset = 0 ,
70
66
)
71
67
72
- assert account .entries == entries
73
- assert account .next_account_key is None
68
+ assert mapping_account .entries == entries
69
+ assert mapping_account .next_account_key is None
74
70
75
71
76
72
def test_mapping_account_upate_from_null_key (
77
- solana_client , mapping_key , mapping_account_bytes , entries
73
+ solana_client , mapping_account , mapping_account_bytes , entries
78
74
):
79
- account = PythMappingAccount (
80
- key = mapping_key ,
81
- solana = solana_client ,
82
- )
83
- assert account .entries == []
84
- assert account .next_account_key is None
85
-
86
75
# Replace the last key with a null key
87
76
null_key_bytes = b"\0 " * SolanaPublicKey .LENGTH
88
77
@@ -92,25 +81,20 @@ def test_mapping_account_upate_from_null_key(
92
81
# Take the original bytes and add a null key to the end
93
82
bad_bytes = mapping_account_bytes [:offset ] + null_key_bytes
94
83
95
- account .update_from (
84
+ mapping_account .update_from (
96
85
buffer = bad_bytes ,
97
86
version = _VERSION_2 ,
98
87
offset = 0 ,
99
88
)
100
89
101
90
# The last key in the list is null, so remove it
102
- expected = entries [: len ( entries ) - 1 ]
91
+ expected = entries [:- 1 ]
103
92
104
- assert account .entries == expected
105
- assert account .next_account_key is None
93
+ assert mapping_account .entries == expected
94
+ assert mapping_account .next_account_key is None
106
95
107
96
108
- def test_mapping_account_str (mapping_key , solana_client ):
109
- actual = str (
110
- PythMappingAccount (
111
- key = mapping_key ,
112
- solana = solana_client ,
113
- )
114
- )
115
- expected = f"PythMappingAccount ({ mapping_key } )"
97
+ def test_mapping_account_str (mapping_account , solana_client ):
98
+ actual = str (mapping_account )
99
+ expected = f"PythMappingAccount ({ mapping_account .key } )"
116
100
assert actual == expected
0 commit comments