|
4 | 4 | Grant,
|
5 | 5 | } from "../../../__fixtures__/misc/output-impl-interfaces-gen/cosmos/authz/v1beta1/authz";
|
6 | 6 | import { Any } from "../../../__fixtures__/misc/output-impl-interfaces-gen/google/protobuf/any";
|
7 |
| - |
| 7 | +import { SendAuthorization } from "../../../__fixtures__/misc/output-impl-interfaces-gen/cosmos/bank/v1beta1/authz"; |
8 | 8 |
|
9 | 9 | describe("implements interface works", () => {
|
10 | 10 | it("encodes and decodes", () => {
|
@@ -214,4 +214,73 @@ describe("implements interface works", () => {
|
214 | 214 | throw new Error("auth can't be empty");
|
215 | 215 | }
|
216 | 216 | });
|
| 217 | + |
| 218 | + it("toSDK for interface", () => { |
| 219 | + const data = Grant.encode({ |
| 220 | + authorization: { |
| 221 | + spendLimit: [ |
| 222 | + { |
| 223 | + denom: "d", |
| 224 | + amount: "1", |
| 225 | + }, |
| 226 | + ], |
| 227 | + }, |
| 228 | + expiration: new Date("2020-01-01"), |
| 229 | + }).finish(); |
| 230 | + |
| 231 | + const message = Grant.decode(data); |
| 232 | + |
| 233 | + const SDK = Grant.toSDK(message); |
| 234 | + |
| 235 | + expect(SDK).toMatchSnapshot(); |
| 236 | + }); |
| 237 | + |
| 238 | + it("fromSDK for extended interface", () => { |
| 239 | + const message = Grant.fromSDK({ |
| 240 | + authorization: { |
| 241 | + spend_limit: [ |
| 242 | + { |
| 243 | + denom: "d", |
| 244 | + amount: "1", |
| 245 | + }, |
| 246 | + ], |
| 247 | + }, |
| 248 | + expiration: new Date("2020-01-01"), |
| 249 | + }); |
| 250 | + |
| 251 | + const data = Grant.encode(message).finish(); |
| 252 | + |
| 253 | + const decodedMessage = Grant.decode(data); |
| 254 | + |
| 255 | + if (decodedMessage.authorization) { |
| 256 | + if (SendAuthorization.is(decodedMessage.authorization)) { |
| 257 | + expect(decodedMessage.authorization.spendLimit[0].denom).toBe("d"); |
| 258 | + expect(decodedMessage.authorization.spendLimit[0].amount).toBe("1"); |
| 259 | + } else { |
| 260 | + throw new Error("should be SendAuthorization"); |
| 261 | + } |
| 262 | + } else { |
| 263 | + throw new Error("auth can't be empty"); |
| 264 | + } |
| 265 | + }); |
| 266 | + |
| 267 | + it("toAmino for interface", () => { |
| 268 | + const data = Grant.encode({ |
| 269 | + authorization: { |
| 270 | + spendLimit: [ |
| 271 | + { |
| 272 | + denom: "d", |
| 273 | + amount: "1", |
| 274 | + }, |
| 275 | + ], |
| 276 | + }, |
| 277 | + expiration: new Date("2020-01-01"), |
| 278 | + }).finish(); |
| 279 | + |
| 280 | + const message = Grant.decode(data); |
| 281 | + |
| 282 | + const amino = Grant.toAmino(message); |
| 283 | + |
| 284 | + expect(amino).toMatchSnapshot(); |
| 285 | + }); |
217 | 286 | });
|
0 commit comments