Skip to content

Commit

Permalink
Standardize casing in identifiers (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongph87 authored Oct 24, 2024
1 parent 7c1ff76 commit 023fd56
Show file tree
Hide file tree
Showing 60 changed files with 268 additions and 259 deletions.
4 changes: 2 additions & 2 deletions StellarDotnetSdk.Tests/Assets/ChangeTrustAssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void TestCreateLiquidityPoolParameters()
var liquidityPoolShareChangeTrustAsset2 =
(LiquidityPoolShareChangeTrustAsset)ChangeTrustAsset.FromXdr(liquidityPoolShareChangeTrustAsset.ToXdr());

Assert.AreEqual(liquidityPoolShareChangeTrustAsset.Parameters.GetID(),
liquidityPoolShareChangeTrustAsset2.Parameters.GetID());
Assert.AreEqual(liquidityPoolShareChangeTrustAsset.Parameters.GetId(),
liquidityPoolShareChangeTrustAsset2.Parameters.GetId());
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TestEquality()
var trustlineAsset = (LiquidityPoolShareTrustlineAsset)TrustlineAsset.Create(
LiquidityPoolParameters.Create(LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetA, assetB, 30));
var trustlineAsset2 = new LiquidityPoolShareTrustlineAsset(trustlineAsset.ID);
var trustlineAsset2 = new LiquidityPoolShareTrustlineAsset(trustlineAsset.Id);
Assert.IsTrue(trustlineAsset.Equals(trustlineAsset2));
}

Expand Down
14 changes: 7 additions & 7 deletions StellarDotnetSdk.Tests/Assets/TrustlineAssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void TestCreateParameters()
var trustlineAsset = (LiquidityPoolShareTrustlineAsset)TrustlineAsset.Create(
LiquidityPoolParameters.Create(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetA, assetB, 30));
var trustlineAsset2 = new LiquidityPoolShareTrustlineAsset(trustlineAsset.ID);
Assert.AreEqual(trustlineAsset.ID, trustlineAsset2.ID);
var trustlineAsset2 = new LiquidityPoolShareTrustlineAsset(trustlineAsset.Id);
Assert.AreEqual(trustlineAsset.Id, trustlineAsset2.Id);
}

[TestMethod]
Expand All @@ -56,8 +56,8 @@ public void TestCreateShareChangeTrust()
var trustlineAsset =
(LiquidityPoolShareTrustlineAsset)TrustlineAsset.Create(
new LiquidityPoolShareChangeTrustAsset(liquidityPoolParameters));
var trustlineAsset2 = new LiquidityPoolShareTrustlineAsset(trustlineAsset.ID);
Assert.AreEqual(trustlineAsset.ID, trustlineAsset2.ID);
var trustlineAsset2 = new LiquidityPoolShareTrustlineAsset(trustlineAsset.Id);
Assert.AreEqual(trustlineAsset.Id, trustlineAsset2.Id);
}

[TestMethod]
Expand All @@ -75,8 +75,8 @@ public void TestCreateLiquidityPoolId()
var trustlineAsset =
(LiquidityPoolShareTrustlineAsset)TrustlineAsset.Create(
new LiquidityPoolShareChangeTrustAsset(liquidityPoolParameters));
var trustlineAsset2 = (LiquidityPoolShareTrustlineAsset)TrustlineAsset.Create(trustlineAsset.ID);
Assert.AreEqual(trustlineAsset.ID, trustlineAsset2.ID);
var trustlineAsset2 = (LiquidityPoolShareTrustlineAsset)TrustlineAsset.Create(trustlineAsset.Id);
Assert.AreEqual(trustlineAsset.Id, trustlineAsset2.Id);
}

[TestMethod]
Expand Down Expand Up @@ -132,6 +132,6 @@ public void TestLiquidityPoolShareTrustlineAsset()
1000));
var xdrAsset = asset.ToXdr();
var decodedAsset = (LiquidityPoolShareTrustlineAsset)TrustlineAsset.FromXdr(xdrAsset);
CollectionAssert.AreEqual(asset.ID.Hash, decodedAsset.ID.Hash);
CollectionAssert.AreEqual(asset.Id.Hash, decodedAsset.Id.Hash);
}
}
2 changes: 1 addition & 1 deletion StellarDotnetSdk.Tests/ClaimLiquidityAtomTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TestFromXdr()
claimLiquidityAtomXdr.AssetBought = asset1.ToXdr();
claimLiquidityAtomXdr.AssetSold = asset2.ToXdr();

var liquidityPool = new LiquidityPoolID(LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
var liquidityPool = new LiquidityPoolId(LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
asset1, asset2, 100);
claimLiquidityAtomXdr.LiquidityPoolID = liquidityPool.ToXdr();
var claimAtom = new StellarDotnetSdk.Xdr.ClaimAtom
Expand Down
8 changes: 4 additions & 4 deletions StellarDotnetSdk.Tests/LedgerEntryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,9 +1343,9 @@ public void TestStateArchivalSettings()
var decodedConfigSetting = (StateArchivalSettings)LedgerEntry.FromXdrBase64(entryXdrBase64);

// Assert
Assert.AreEqual(xdrConfigSetting.MaxEntryTTL.InnerValue, decodedConfigSetting.MaxEntryTTL);
Assert.AreEqual(xdrConfigSetting.MinTemporaryTTL.InnerValue, decodedConfigSetting.MinTemporaryTTL);
Assert.AreEqual(xdrConfigSetting.MinPersistentTTL.InnerValue, decodedConfigSetting.MinPersistentTTL);
Assert.AreEqual(xdrConfigSetting.MaxEntryTTL.InnerValue, decodedConfigSetting.MaxEntryTtl);
Assert.AreEqual(xdrConfigSetting.MinTemporaryTTL.InnerValue, decodedConfigSetting.MinTemporaryTtl);
Assert.AreEqual(xdrConfigSetting.MinPersistentTTL.InnerValue, decodedConfigSetting.MinPersistentTtl);
Assert.AreEqual(xdrConfigSetting.PersistentRentRateDenominator.InnerValue,
decodedConfigSetting.PersistentRentRateDenominator);
Assert.AreEqual(xdrConfigSetting.TempRentRateDenominator.InnerValue,
Expand Down Expand Up @@ -1508,7 +1508,7 @@ public void TestLedgerEntryTtlWithAllPropertiesPopulated()
var os = new XdrDataOutputStream();
StellarDotnetSdk.Xdr.LedgerEntry.LedgerEntryData.Encode(os, xdrLedgerEntryData);
var entryXdrBase64 = Convert.ToBase64String(os.ToArray());
var decodedLedgerEntry = (LedgerEntryTTL)LedgerEntry.FromXdrBase64(entryXdrBase64);
var decodedLedgerEntry = (LedgerEntryTtl)LedgerEntry.FromXdrBase64(entryXdrBase64);

// Assert
CollectionAssert.AreEqual(xdrTtlEntry.KeyHash.InnerValue, decodedLedgerEntry.KeyHash);
Expand Down
11 changes: 6 additions & 5 deletions StellarDotnetSdk.Tests/LedgerKeyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void TestLedgerKeyTrustline()
public void TestLedgerKeyClaimableBalance()
{
var balanceId = Util.HexToBytes("c582697b67cbec7f9ce64f4dc67bfb2bfd26318bb9f964f4d70e3f41f650b1e6");

var ledgerKey = LedgerKey.ClaimableBalance(balanceId);

// Act
Expand All @@ -105,14 +106,14 @@ public void TestLedgerKeyLiquidityPool()
{
var hash = new byte[]
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 };
var ledgerKey = LedgerKey.LiquidityPool(new LiquidityPoolID(hash));
var ledgerKey = LedgerKey.LiquidityPool(new LiquidityPoolId(hash));

// Act
var ledgerKeyXdrBase64 = ledgerKey.ToXdrBase64();
var decodedLedgerKey = (LedgerKeyLiquidityPool)LedgerKey.FromXdrBase64(ledgerKeyXdrBase64);

// Assert
CollectionAssert.AreEqual(hash, decodedLedgerKey.LiquidityPoolID.Hash);
CollectionAssert.AreEqual(hash, decodedLedgerKey.LiquidityPoolId.Hash);
}

[TestMethod]
Expand Down Expand Up @@ -189,17 +190,17 @@ public void TestLedgerKeyConfigSetting()
var decodedLedgerKey = (LedgerKeyConfigSetting)LedgerKey.FromXdrBase64(ledgerKeyXdrBase64);

// Assert
Assert.AreEqual(ledgerKey.ConfigSettingID.InnerValue, decodedLedgerKey.ConfigSettingID.InnerValue);
Assert.AreEqual(ledgerKey.ConfigSettingId.InnerValue, decodedLedgerKey.ConfigSettingId.InnerValue);
}

[TestMethod]
public void TestLedgerKeyTtlCreationFromValidHashString()
{
var ledgerKey = (LedgerKeyTTL)LedgerKey.TTL("AQIDBAUGBwgJAAECAwQFBgcICQABAgMEBQYHCAkAAQI=");
var ledgerKey = (LedgerKeyTtl)LedgerKey.Ttl("AQIDBAUGBwgJAAECAwQFBgcICQABAgMEBQYHCAkAAQI=");

// Act
var ledgerKeyXdrBase64 = ledgerKey.ToXdrBase64();
var decodedLedgerKey = (LedgerKeyTTL)LedgerKey.FromXdrBase64(ledgerKeyXdrBase64);
var decodedLedgerKey = (LedgerKeyTtl)LedgerKey.FromXdrBase64(ledgerKeyXdrBase64);

// Assert
CollectionAssert.AreEqual(ledgerKey.Key, decodedLedgerKey.Key);
Expand Down
10 changes: 5 additions & 5 deletions StellarDotnetSdk.Tests/LiquidityPoolIDTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void TestCreate()
var assetA = Asset.Create("native");
var assetB = Asset.CreateNonNativeAsset("ABC", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3");

var liquidityPoolId = new LiquidityPoolID(
var liquidityPoolId = new LiquidityPoolId(
XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT, assetA, assetB,
LiquidityPoolParameters.Fee);
Assert.AreEqual("cc22414997d7e3d9a9ac3b1d65ca9cc3e5f35ce33e0bd6a885648b11aaa3b72d", liquidityPoolId.ToString());
Expand All @@ -28,7 +28,7 @@ public void TestNotLexicographicOrder()
var assetB = Asset.CreateNonNativeAsset("ABC", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3");

Assert.ThrowsException<ArgumentException>(
() => new LiquidityPoolID(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
() => new LiquidityPoolId(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetB, assetA,
LiquidityPoolParameters.Fee), "Asset A must be < Asset B (Lexicographic Order)");
}
Expand All @@ -39,7 +39,7 @@ public void TestEquality()
var assetA = Asset.Create("native");
var assetB = Asset.CreateNonNativeAsset("ABC", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3");

var pool1 = new LiquidityPoolID(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
var pool1 = new LiquidityPoolId(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetA,
assetB, LiquidityPoolParameters.Fee);
Assert.AreEqual(pool1, pool1);
Expand All @@ -52,10 +52,10 @@ public void TestInequality()
var assetB = Asset.CreateNonNativeAsset("ABC", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3");
var assetC = Asset.CreateNonNativeAsset("ABCD", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3");

var pool1 = new LiquidityPoolID(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
var pool1 = new LiquidityPoolId(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetA,
assetB, LiquidityPoolParameters.Fee);
var pool2 = new LiquidityPoolID(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
var pool2 = new LiquidityPoolId(XDR.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetB,
assetC, LiquidityPoolParameters.Fee);
Assert.AreNotEqual(pool1, pool2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void TestCreateContractOperationWithMissingSourceAccount()
var xdrOperation = operation.ToXdr();
var decodedOperation = (CreateContractOperation)Operation.FromXdr(xdrOperation);

var contractIdPreimage = (ContractIDAddressPreimage)operation.HostFunction.ContractIDPreimage;
var decodedContractIdPreimage = (ContractIDAddressPreimage)decodedOperation.HostFunction.ContractIDPreimage;
var contractIdPreimage = (ContractIdAddressPreimage)operation.HostFunction.ContractIdPreimage;
var decodedContractIdPreimage = (ContractIdAddressPreimage)decodedOperation.HostFunction.ContractIdPreimage;

var address = (SCAccountId)contractIdPreimage.Address;
var decodedAddress = (SCAccountId)decodedContractIdPreimage.Address;
Expand Down Expand Up @@ -90,8 +90,8 @@ public void TestCreateContractOperationFromAddressWithMissingAuthorizationEntry(
var xdrOperation = operation.ToXdr();
var decodedOperation = (CreateContractOperation)Operation.FromXdr(xdrOperation);

var contractIdPreimage = (ContractIDAddressPreimage)operation.HostFunction.ContractIDPreimage;
var decodedContractIdPreimage = (ContractIDAddressPreimage)decodedOperation.HostFunction.ContractIDPreimage;
var contractIdPreimage = (ContractIdAddressPreimage)operation.HostFunction.ContractIdPreimage;
var decodedContractIdPreimage = (ContractIdAddressPreimage)decodedOperation.HostFunction.ContractIdPreimage;

var address = (SCAccountId)contractIdPreimage.Address;
var decodedAddress = (SCAccountId)decodedContractIdPreimage.Address;
Expand Down Expand Up @@ -126,8 +126,8 @@ public void TestCreateContractOperationFromAddressWithValidArguments()
var xdrOperation = operation.ToXdr();
var decodedOperation = (CreateContractOperation)Operation.FromXdr(xdrOperation);

var contractIdPreimage = (ContractIDAddressPreimage)operation.HostFunction.ContractIDPreimage;
var decodedContractIdPreimage = (ContractIDAddressPreimage)decodedOperation.HostFunction.ContractIDPreimage;
var contractIdPreimage = (ContractIdAddressPreimage)operation.HostFunction.ContractIdPreimage;
var decodedContractIdPreimage = (ContractIdAddressPreimage)decodedOperation.HostFunction.ContractIdPreimage;

var address = (SCAccountId)contractIdPreimage.Address;
var decodedAddress = (SCAccountId)decodedContractIdPreimage.Address;
Expand Down Expand Up @@ -189,8 +189,8 @@ public void TestCreateContractOperationWithStellarAssetExecutable()
var xdrOperation = operation.ToXdr();
var decodedOperation = (CreateContractOperation)Operation.FromXdr(xdrOperation);

var contractIdPreimage = (ContractIDAssetPreimage)operation.HostFunction.ContractIDPreimage;
var decodedContractIdPreimage = (ContractIDAssetPreimage)decodedOperation.HostFunction.ContractIDPreimage;
var contractIdPreimage = (ContractIdAssetPreimage)operation.HostFunction.ContractIdPreimage;
var decodedContractIdPreimage = (ContractIdAssetPreimage)decodedOperation.HostFunction.ContractIdPreimage;

var asset = (AssetTypeCreditAlphaNum4)contractIdPreimage.Asset;
var decodedAsset = (AssetTypeCreditAlphaNum4)decodedContractIdPreimage.Asset;
Expand Down
20 changes: 10 additions & 10 deletions StellarDotnetSdk.Tests/Operations/OperationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public void TestRevokeClaimableBalanceSponsorshipOperation()
{
var operation =
RevokeLedgerEntrySponsorshipOperation.ForClaimableBalance(
"c8789370cda62cdb5be83642f5af61829c0c77afde7d0fb7577a8f320467563f");
"00000000d1d73327fc560cc09f54a11c7a64180611e1f480f3bf60117e41d19d9593b780");

var xdrOperation = operation.ToXdr();
var decodedOperation = (RevokeLedgerEntrySponsorshipOperation)Operation.FromXdr(xdrOperation);
Expand Down Expand Up @@ -873,7 +873,7 @@ public void TestLiquidityPoolDepositOperationConstructor1()
var parsedOperation = (LiquidityPoolDepositOperation)Operation.FromXdr(xdr);
Assert.IsNotNull(parsedOperation.SourceAccount);
Assert.AreEqual(source.AccountId, parsedOperation.SourceAccount.AccountId);
Assert.AreEqual(operation.LiquidityPoolID, parsedOperation.LiquidityPoolID);
Assert.AreEqual(operation.LiquidityPoolId, parsedOperation.LiquidityPoolId);
Assert.AreEqual(operation.MaxAmountA, parsedOperation.MaxAmountA);
Assert.AreEqual(operation.MaxAmountB, parsedOperation.MaxAmountB);
Assert.AreEqual(operation.MinPrice, parsedOperation.MinPrice);
Expand All @@ -894,7 +894,7 @@ public void TestLiquidityPoolDepositOperationConstructor2()
var assetA = Asset.Create($"EUR:{keypairAssetA.AccountId}");
var assetB = Asset.Create($"USD:{keypairAssetB.AccountId}");

var liquidityPoolId = new LiquidityPoolID(
var liquidityPoolId = new LiquidityPoolId(
xdrSDK.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetA,
assetB,
Expand All @@ -910,7 +910,7 @@ public void TestLiquidityPoolDepositOperationConstructor2()
var parsedOperation = (LiquidityPoolDepositOperation)Operation.FromXdr(xdr);
Assert.IsNotNull(parsedOperation.SourceAccount);
Assert.AreEqual(source.AccountId, parsedOperation.SourceAccount.AccountId);
Assert.AreEqual(operation.LiquidityPoolID, parsedOperation.LiquidityPoolID);
Assert.AreEqual(operation.LiquidityPoolId, parsedOperation.LiquidityPoolId);
Assert.AreEqual(operation.MaxAmountA, parsedOperation.MaxAmountA);
Assert.AreEqual(operation.MaxAmountB, parsedOperation.MaxAmountB);
Assert.AreEqual(operation.MinPrice, parsedOperation.MinPrice);
Expand Down Expand Up @@ -981,7 +981,7 @@ public void TestLiquidityPoolWithdrawOperationConstructor2()
var assetA = Asset.Create($"EUR:{keypairAssetA.AccountId}");
var assetB = Asset.Create($"USD:{keypairAssetB.AccountId}");

var liquidityPoolId = new LiquidityPoolID(
var liquidityPoolId = new LiquidityPoolId(
xdrSDK.LiquidityPoolType.LiquidityPoolTypeEnum.LIQUIDITY_POOL_CONSTANT_PRODUCT,
assetA,
assetB,
Expand Down Expand Up @@ -1063,8 +1063,8 @@ public void TestCreateContractOperation()
var decodedExecutable = (ContractExecutableWasm)decodedHostFunction.Executable;
Assert.AreEqual(executable.WasmHash.ToLower(), decodedExecutable.WasmHash.ToLower());

var preimage = (ContractIDAddressPreimage)hostFunction.ContractIDPreimage;
var decodedPreimage = (ContractIDAddressPreimage)decodedHostFunction.ContractIDPreimage;
var preimage = (ContractIdAddressPreimage)hostFunction.ContractIdPreimage;
var decodedPreimage = (ContractIdAddressPreimage)decodedHostFunction.ContractIdPreimage;
Assert.AreEqual(((SCAccountId)preimage.Address).InnerValue, ((SCAccountId)decodedPreimage.Address).InnerValue);
CollectionAssert.AreEqual(preimage.Salt, decodedPreimage.Salt);

Expand Down Expand Up @@ -1157,10 +1157,10 @@ public void TestDeploySacOperation()
Assert.IsInstanceOfType(hostFunction.Executable, typeof(ContractExecutableStellarAsset));
Assert.IsInstanceOfType(decodedHostFunction.Executable, typeof(ContractExecutableStellarAsset));

Assert.IsInstanceOfType(hostFunction.ContractIDPreimage, typeof(ContractIDAssetPreimage));
Assert.IsInstanceOfType(decodedHostFunction.ContractIDPreimage, typeof(ContractIDAssetPreimage));
Assert.IsInstanceOfType(hostFunction.ContractIdPreimage, typeof(ContractIdAssetPreimage));
Assert.IsInstanceOfType(decodedHostFunction.ContractIdPreimage, typeof(ContractIdAssetPreimage));

var decodedAsset = ((ContractIDAssetPreimage)decodedHostFunction.ContractIDPreimage).Asset;
var decodedAsset = ((ContractIdAssetPreimage)decodedHostFunction.ContractIdPreimage).Asset;
Assert.AreEqual(((AssetTypeCreditAlphaNum4)asset).Code, ((AssetTypeCreditAlphaNum4)decodedAsset).Code);
Assert.AreEqual(((AssetTypeCreditAlphaNum4)asset).Issuer, ((AssetTypeCreditAlphaNum4)decodedAsset).Issuer);
}
Expand Down
Loading

0 comments on commit 023fd56

Please sign in to comment.