Skip to content

Commit

Permalink
Merge pull request #35 from Salvionied/fix-tws
Browse files Browse the repository at this point in the history
fix-tws
  • Loading branch information
Salvionied authored Sep 2, 2024
2 parents 3da936b + 7ecf959 commit f0c9162
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ApolloBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,13 @@ func TestFeePadding(t *testing.T) {
if err != nil {
t.Error(err)
}
if built.GetTx().TransactionBody.Fee != 683641 {
if built.GetTx().TransactionBody.Fee != 683509 {
t.Error("Tx is not correct", built.GetTx().TransactionBody.Fee)
}
if built.GetTx().TransactionBody.Outputs[0].Lovelace() != 1_000_000 {
t.Error("Tx is not correct")
}
if built.GetTx().TransactionBody.Outputs[1].Lovelace() != 13316359 {
if built.GetTx().TransactionBody.Outputs[1].Lovelace() != 13316491 {
t.Error("Tx is not correct", built.GetTx().TransactionBody.Outputs[1].Lovelace())
}
if built.GetTx().TransactionBody.Outputs[0].IsPostAlonzo && built.GetTx().TransactionBody.Outputs[0].GetDatumHash() != nil {
Expand Down
4 changes: 2 additions & 2 deletions serialization/Transaction/Transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func TestMarshalAndUnmarshal(t *testing.T) {
}

marshaled, _ := tx.Bytes()
if hex.EncodeToString(marshaled) != "84a3008182430102030001f60200a1049ffff4f6" {
t.Error("Invalid marshaling", hex.EncodeToString(marshaled), "Expected", "84a3008182430102030001f60200a1049ffff4f6")
if hex.EncodeToString(marshaled) != "84a3008182430102030001f60200a0f4f6" {
t.Error("Invalid marshaling", hex.EncodeToString(marshaled), "Expected", "84a3008182430102030001f60200a0f4f6")
}
tx2 := Transaction.Transaction{}
err := cbor.Unmarshal(marshaled, &tx2)
Expand Down
2 changes: 1 addition & 1 deletion serialization/TransactionOutput/TransactionOutput_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestPostAlonzo(t *testing.T) {
}

func TestDeSerializeTxWithPostAlonzoOut(t *testing.T) {
cborHex := "84a500838258205628043acaccaf3e07ce6d93bec8da6ae013d2546aa1f491c68dfa2942e6aab401825820250cb6fab4bab5fe0746748cdb8dd42b545328ecc8109e16cd56c0ca9382c7bb028258205e9344d4529b623cb1e17b5a041f58f8275e0fdea54c52a7dc73e0d47ff2fe1a010183a300581d712618e94cdb06792f05ae9b1ec78b0231f4b7f4215b1b4cf52e6342de01821a00e4e1c0a0028201d81858bfd8799fd8799f4040ffd8799f581cf43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc5354441474958ffd8799f581cfd011feb9dc34f85e58e56838989816343f5c62619a82f6a089f05484c414749585f4144415f4e4654ff1903e51b002904d642c7b27c1b7fffffffffffffff581c37dce7298152979f0d0ff71fb2d0c759b298ac6fa7bc56b928ffc1bcd8799f581cf68864a338ae8ed81f61114d857cb6a215c8e685aa5c43bc1f879cceff1a009896801a4d6fd4bcff82583901bb2ff620c0dd8b0adc19e6ffadea1a150c85d1b22d05e2db10c55c613b8c8a100c16cf62b9c2bacc40453aaa67ced633993f2b4eec5b88e41a000fea4c8258390137dce7298152979f0d0ff71fb2d0c759b298ac6fa7bc56b928ffc1bcf68864a338ae8ed81f61114d857cb6a215c8e685aa5c43bc1f879cce821a0633d59aab581c10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b6a1444745524f1a001e8480581c25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20ca147534f43494554591b00000019e1ae3741581c279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3fa144534e454b1928b0581c29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c6a1434d494e1a0cb30355581c533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0a144494e44591a156f14e4581c5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef064415d114a1434941471b0000002e921a6381581c8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaaa1444d494c4b05581c8b4e239aef4d1d1bc5dd628ff3ce34d392d632e5cda83e42d6fcb1cca14b586572636865723234393301581cd480f68af028d6324ad77df489176e7f5e5d793e09a6b133392ff2f6aa524e7563617374496e63657074696f6e31343101524e7563617374496e63657074696f6e32303601524e7563617374496e63657074696f6e33323101524e7563617374496e63657074696f6e33383501524e7563617374496e63657074696f6e34303001524e7563617374496e63657074696f6e36333701524e7563617374496e63657074696f6e36373001524e7563617374496e63657074696f6e37383701524e7563617374496e63657074696f6e38333301524e7563617374496e63657074696f6e38373001581ce3ff4ab89245ede61b3e2beab0443dbcc7ea8ca2c017478e4e8990e2a549746170707930333831014974617070793034313901497461707079313430390149746170707931343437014974617070793135353001581cf0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9aa24a626c7565646573657274014a6d6f6e74626c616e636f01021a000342dd031a05fd33e3081a05fd32b7a1049ffff5f6"
cborHex := "84a500838258205628043acaccaf3e07ce6d93bec8da6ae013d2546aa1f491c68dfa2942e6aab401825820250cb6fab4bab5fe0746748cdb8dd42b545328ecc8109e16cd56c0ca9382c7bb028258205e9344d4529b623cb1e17b5a041f58f8275e0fdea54c52a7dc73e0d47ff2fe1a010183a300581d712618e94cdb06792f05ae9b1ec78b0231f4b7f4215b1b4cf52e6342de01821a00e4e1c0a0028201d81858bfd8799fd8799f4040ffd8799f581cf43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc5354441474958ffd8799f581cfd011feb9dc34f85e58e56838989816343f5c62619a82f6a089f05484c414749585f4144415f4e4654ff1903e51b002904d642c7b27c1b7fffffffffffffff581c37dce7298152979f0d0ff71fb2d0c759b298ac6fa7bc56b928ffc1bcd8799f581cf68864a338ae8ed81f61114d857cb6a215c8e685aa5c43bc1f879cceff1a009896801a4d6fd4bcff82583901bb2ff620c0dd8b0adc19e6ffadea1a150c85d1b22d05e2db10c55c613b8c8a100c16cf62b9c2bacc40453aaa67ced633993f2b4eec5b88e41a000fea4c8258390137dce7298152979f0d0ff71fb2d0c759b298ac6fa7bc56b928ffc1bcf68864a338ae8ed81f61114d857cb6a215c8e685aa5c43bc1f879cce821a0633d59aab581c10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b6a1444745524f1a001e8480581c25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20ca147534f43494554591b00000019e1ae3741581c279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3fa144534e454b1928b0581c29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c6a1434d494e1a0cb30355581c533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0a144494e44591a156f14e4581c5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef064415d114a1434941471b0000002e921a6381581c8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaaa1444d494c4b05581c8b4e239aef4d1d1bc5dd628ff3ce34d392d632e5cda83e42d6fcb1cca14b586572636865723234393301581cd480f68af028d6324ad77df489176e7f5e5d793e09a6b133392ff2f6aa524e7563617374496e63657074696f6e31343101524e7563617374496e63657074696f6e32303601524e7563617374496e63657074696f6e33323101524e7563617374496e63657074696f6e33383501524e7563617374496e63657074696f6e34303001524e7563617374496e63657074696f6e36333701524e7563617374496e63657074696f6e36373001524e7563617374496e63657074696f6e37383701524e7563617374496e63657074696f6e38333301524e7563617374496e63657074696f6e38373001581ce3ff4ab89245ede61b3e2beab0443dbcc7ea8ca2c017478e4e8990e2a549746170707930333831014974617070793034313901497461707079313430390149746170707931343437014974617070793135353001581cf0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9aa24a626c7565646573657274014a6d6f6e74626c616e636f01021a000342dd031a05fd33e3081a05fd32b7a0f5f6"

decoded_cbor, _ := hex.DecodeString(cborHex)
var tx Transaction.Transaction
Expand Down
30 changes: 21 additions & 9 deletions serialization/TransactionWitnessSet/TransactionWitnessSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,26 @@ func (tws *TransactionWitnessSet) MarshalCBOR() ([]byte, error) {
Redeemer: tws.Redeemer,
})
}
return cbor.Marshal(normaltws{
VkeyWitnesses: tws.VkeyWitnesses,
NativeScripts: tws.NativeScripts,
BootstrapWitnesses: tws.BootstrapWitnesses,
PlutusV1Script: tws.PlutusV1Script,
PlutusV2Script: tws.PlutusV2Script,
PlutusData: &tws.PlutusData,
Redeemer: tws.Redeemer,
})
if len(tws.PlutusData) > 0 {
return cbor.Marshal(normaltws{
VkeyWitnesses: tws.VkeyWitnesses,
NativeScripts: tws.NativeScripts,
BootstrapWitnesses: tws.BootstrapWitnesses,
PlutusV1Script: tws.PlutusV1Script,
PlutusV2Script: tws.PlutusV2Script,
PlutusData: &tws.PlutusData,
Redeemer: tws.Redeemer,
})
} else {
return cbor.Marshal(normaltws{
VkeyWitnesses: tws.VkeyWitnesses,
NativeScripts: tws.NativeScripts,
BootstrapWitnesses: tws.BootstrapWitnesses,
PlutusV1Script: tws.PlutusV1Script,
PlutusV2Script: tws.PlutusV2Script,
PlutusData: nil,
Redeemer: tws.Redeemer,
})
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestMarshalAndUnmarshalNoScripts(t *testing.T) {
if err != nil {
t.Errorf("Error marshaling TransactionWitnessSet: %v", err)
}
if hex.EncodeToString(twsBytes) != "a1049fff" {
if hex.EncodeToString(twsBytes) != "a0" {
t.Error("TransactionWitnessSet marshaled incorrectly", hex.EncodeToString(twsBytes))
}
}
Expand Down
2 changes: 1 addition & 1 deletion tmp/genesis_params_time.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2024-08-30T15:36:02.510108+02:00"
"2024-09-02T04:08:00.895341+02:00"
2 changes: 1 addition & 1 deletion tmp/latest_epoch.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"active_stake":"22600232613963850","block_count":11327,"end_time":1725227091,"epoch":506,"fees":"34716368529","first_block_time":1724795119,"last_block_time":1725024949,"output":"42491576564571224","start_time":1724795091,"tx_count":111452}
{"active_stake":"22567839323083531","block_count":714,"end_time":1725659091,"epoch":507,"fees":"2259008704","first_block_time":1725227146,"last_block_time":1725242828,"output":"3011051587143000","start_time":1725227091,"tx_count":6117}
2 changes: 1 addition & 1 deletion tmp/latest_epoch_params.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"min_fee_b":155381,"min_fee_a":44,"max_block_size":90112,"max_tx_size":16384,"max_block_header_size":1100,"key_deposit":"2000000","pool_deposit":"500000000","a0":0.3,"rho":0.003,"tau":0.2,"decentralisation_param":0,"extra_entropy":"","protocol_major_ver":8,"protocol_minor_ver":0,"min_utxo":"4310","min_pool_cost":"170000000","price_mem":0.0577,"price_step":0.0000721,"max_tx_ex_mem":"14000000","max_tx_ex_steps":"10000000000","max_block_ex_mem":"62000000","max_block_ex_steps":"20000000000","max_val_size":"5000","collateral_percent":150,"max_collateral_inputs":3,"coins_per_utxo_word":"4310","coins_per_utxo_byte":""}
{"min_fee_b":155381,"min_fee_a":44,"max_block_size":90112,"max_tx_size":16384,"max_block_header_size":1100,"key_deposit":"2000000","pool_deposit":"500000000","a0":0.3,"rho":0.003,"tau":0.2,"decentralisation_param":0,"extra_entropy":"","protocol_major_ver":9,"protocol_minor_ver":0,"min_utxo":"4310","min_pool_cost":"170000000","price_mem":0.0577,"price_step":0.0000721,"max_tx_ex_mem":"14000000","max_tx_ex_steps":"10000000000","max_block_ex_mem":"62000000","max_block_ex_steps":"20000000000","max_val_size":"5000","collateral_percent":150,"max_collateral_inputs":3,"coins_per_utxo_word":"4310","coins_per_utxo_byte":""}
2 changes: 1 addition & 1 deletion tmp/latest_epoch_params_time.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2024-08-30T15:36:02.554612+02:00"
"2024-09-02T04:08:00.930464+02:00"
2 changes: 1 addition & 1 deletion tmp/latest_epoch_time.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2024-08-30T15:36:02.465511+02:00"
"2024-09-02T04:08:00.860809+02:00"

0 comments on commit f0c9162

Please sign in to comment.