MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

common/test/run-deprecation.c:111–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109/* AUTOGENERATED MOCKS END */
110
111int main(int argc, char *argv[])
112{
113 common_setup(argv[0]);
114
115 assert(version_to_number("v22.11") == 22*YEAR_VAL + 11*MONTH_VAL + 1);
116
117 assert(version_to_number("v22.11rc1") == 22*YEAR_VAL + 11*MONTH_VAL + 1);
118
119 assert(version_to_number("v22.11rc1-1-g123456") == 22*YEAR_VAL + 11*MONTH_VAL + 1);
120
121 /* We insert a 0 so far, but let's check both! */
122 assert(version_to_number("v25.1") == 25*YEAR_VAL + 1*MONTH_VAL + 1);
123 assert(version_to_number("v25.02") == 25*YEAR_VAL + 2*MONTH_VAL + 1);
124 assert(version_to_number("v25.12") == 25*YEAR_VAL + 12*MONTH_VAL + 1);
125
126 assert(version_to_number("v25.12.9") == 25*YEAR_VAL + 12*MONTH_VAL + 9 + 1);
127
128 /* Malformed */
129 assert(version_to_number("v25.12.") == 0);
130 assert(version_to_number("v25.12.10") == 0);
131 assert(version_to_number("v25.0") == 0);
132 assert(version_to_number("v25.") == 0);
133 assert(version_to_number("v25..") == 0);
134 assert(version_to_number("v25.13") == 0);
135 assert(version_to_number("v100.12") == 0);
136 assert(version_to_number("v25.") == 0);
137 assert(version_to_number("v25") == 0);
138 assert(version_to_number("v") == 0);
139 assert(version_to_number("") == 0);
140 assert(version_to_number("25.12") == 0);
141
142 test_next_version = "v23.08";
143 /* Deprecated in future */
144 assert(deprecation("v24.08", NULL) == DEPRECATED_SOON);
145 assert(deprecation("v23.09", NULL) == DEPRECATED_SOON);
146 /* Just deprecated for 6 months */
147 assert(deprecation("v23.08", NULL) == DEPRECATED);
148 assert(deprecation("v23.07", NULL) == DEPRECATED);
149 assert(deprecation("v23.06", NULL) == DEPRECATED);
150 assert(deprecation("v23.05", NULL) == DEPRECATED);
151 assert(deprecation("v23.04", NULL) == DEPRECATED);
152 assert(deprecation("v23.03", NULL) == DEPRECATED);
153 /* At 6 months, it complains */
154 assert(deprecation("v23.02", NULL) == DEPRECATED_COMPLAIN);
155 /* After that, you need to switch it on */
156 assert(deprecation("v23.01", NULL) == DEPRECATED_BEG);
157 assert(deprecation("v22.12", NULL) == DEPRECATED_BEG);
158 assert(deprecation("v22.11", NULL) == DEPRECATED_BEG);
159 assert(deprecation("v22.01", NULL) == DEPRECATED_BEG);
160
161 /* Non-default end works */
162 assert(deprecation("v23.09", "v23.10") == DEPRECATED_SOON);
163 assert(deprecation("v23.08", "v23.09") == DEPRECATED);
164 assert(deprecation("v23.07", "v23.08") == DEPRECATED_COMPLAIN);
165 assert(deprecation("v23.06", "v23.07") == DEPRECATED_BEG);
166
167 common_shutdown();
168}

Callers

nothing calls this directly

Calls 4

common_setupFunction · 0.85
version_to_numberFunction · 0.85
deprecationFunction · 0.85
common_shutdownFunction · 0.85

Tested by

no test coverage detected