public int ClaimMonsterCollectionReward( [Argument("AVATAR-ADDRESS", Description = "A hex-encoded avatar address.")] string encodedAddress, [Argument("PATH", Description = "A file path of base64 encoded action.")] string filePath ) { try { Address avatarAddress = new Address(ByteUtil.ParseHex(encodedAddress)); Nekoyume.Action.ClaimMonsterCollectionReward action = new ClaimMonsterCollectionReward { avatarAddress = avatarAddress }; var encoded = new List( new[] { (Text)nameof(Nekoyume.Action.ClaimMonsterCollectionReward), action.PlainValue } ); byte[] raw = Codec.Encode(encoded); File.WriteAllText(filePath, Convert.ToBase64String(raw)); return(0); } catch (Exception e) { _console.Error.WriteLine(e); return(-1); } }
public void ClaimMonsterCollectReward(string addressString, int expectedCode) { var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); var resultCode = _command.ClaimMonsterCollectionReward(addressString, filePath); Assert.Equal(expectedCode, resultCode); if (resultCode == 0) { var rawAction = Convert.FromBase64String(File.ReadAllText(filePath)); var decoded = (List)_codec.Decode(rawAction); string type = (Text)decoded[0]; Assert.Equal(nameof(Nekoyume.Action.ClaimMonsterCollectionReward), type); Dictionary plainValue = (Dictionary)decoded[1]; var action = new ClaimMonsterCollectionReward(); action.LoadPlainValue(plainValue); Assert.Equal(new Address(addressString), action.avatarAddress); } else { Assert.Contains("System.FormatException: Could not find any recognizable digits.", _console.Error.ToString()); } }