@@ -43,6 +43,17 @@ defmodule EthersTest do
43
43
end
44
44
end
45
45
46
+ describe "blob_base_fee" do
47
+ test "returns the correct blob base fee" do
48
+ assert { :ok , blob_base_fee } = Ethers . blob_base_fee ( )
49
+ assert is_integer ( blob_base_fee )
50
+ end
51
+
52
+ test "bang version returns unwrapped value" do
53
+ assert is_integer ( Ethers . blob_base_fee! ( ) )
54
+ end
55
+ end
56
+
46
57
describe "current_block_number" do
47
58
test "returns the current block number" do
48
59
assert { :ok , n } = Ethers . current_block_number ( )
@@ -570,6 +581,73 @@ defmodule EthersTest do
570
581
type: "0x2"
571
582
}
572
583
end
584
+
585
+ test "works with all transaction types" do
586
+ types = [
587
+ Ethers.Transaction.Legacy ,
588
+ Ethers.Transaction.Eip1559 ,
589
+ Ethers.Transaction.Eip2930 ,
590
+ Ethers.Transaction.Eip4844
591
+ ]
592
+
593
+ for type <- types do
594
+ assert { :ok , _tx_hash } =
595
+ Ethers . send_transaction (
596
+ % { value: 1000 } ,
597
+ rpc_client: Ethers.TestRPCModule ,
598
+ from: @ from ,
599
+ type: type ,
600
+ to: "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc" ,
601
+ rpc_opts: [ send_params_to_pid: self ( ) ]
602
+ )
603
+
604
+ type_id = Ethers.Utils . integer_to_hex ( type . type_id ( ) )
605
+
606
+ assert_receive % {
607
+ from: @ from ,
608
+ to: "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc" ,
609
+ value: "0x3E8" ,
610
+ type: ^ type_id
611
+ }
612
+ end
613
+ end
614
+
615
+ test "works with all transaction types and local signer" do
616
+ types = [
617
+ Ethers.Transaction.Legacy ,
618
+ Ethers.Transaction.Eip1559 ,
619
+ Ethers.Transaction.Eip2930
620
+ # Does not work with Anvil without sidecar
621
+ # Ethers.Transaction.Eip4844
622
+ ]
623
+
624
+ for type <- types do
625
+ assert { :ok , tx_hash } =
626
+ Ethers . send_transaction (
627
+ % { value: 1000 } ,
628
+ from: @ from ,
629
+ type: type ,
630
+ to: "0x9965507D1a55bcC2695C58ba16FB37d819B0A4da" ,
631
+ signer: Ethers.Signer.Local ,
632
+ blob_versioned_hashes: [
633
+ Ethers.Utils . hex_decode! (
634
+ "0x01bb9dc6ee48ae6a6f7ffd69a75196a4d49723beedf35981106e8da0efd8f796"
635
+ )
636
+ ] ,
637
+ access_list: access_list_fixture ( ) ,
638
+ signer_opts: [
639
+ private_key: @ from_private_key
640
+ ]
641
+ )
642
+
643
+ wait_for_transaction! ( tx_hash )
644
+
645
+ type_id = Ethers.Utils . integer_to_hex ( type . type_id ( ) )
646
+
647
+ assert % Ethers.Transaction.Signed { payload: % ^ type { } } = Ethers . get_transaction! ( tx_hash )
648
+ assert Ethers . get_transaction_receipt! ( tx_hash ) [ "type" ] == type_id
649
+ end
650
+ end
573
651
end
574
652
575
653
describe "sign_transaction/2" do
@@ -740,4 +818,43 @@ defmodule EthersTest do
740
818
assert Ethers . chain_id! ( ) == 31_337
741
819
end
742
820
end
821
+
822
+ defp access_list_fixture do
823
+ [
824
+ [
825
+ << 7 , 166 , 233 , 85 , 186 , 67 , 69 , 186 , 232 , 58 , 194 , 166 , 250 , 167 , 113 , 253 , 221 , 138 , 32 ,
826
+ 17 >> ,
827
+ [
828
+ << 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
829
+ 0 , 0 , 0 >> ,
830
+ << 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
831
+ 0 , 0 , 1 >> ,
832
+ << 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
833
+ 0 , 0 , 8 >>
834
+ ]
835
+ ] ,
836
+ [
837
+ << 125 , 26 , 250 , 123 , 113 , 143 , 184 , 147 , 219 , 48 , 163 , 171 , 192 , 207 , 198 , 8 , 170 , 207 ,
838
+ 235 , 176 >> ,
839
+ [
840
+ << 20 , 213 , 49 , 41 , 66 , 36 , 14 , 86 , 92 , 86 , 174 , 193 , 24 , 6 , 206 , 88 , 227 , 192 , 227 , 140 ,
841
+ 150 , 38 , 157 , 117 , 156 , 93 , 53 , 162 , 162 , 228 , 164 , 73 >> ,
842
+ << 39 , 1 , 253 , 11 , 38 , 56 , 243 , 61 , 178 , 37 , 217 , 28 , 106 , 219 , 218 , 212 , 101 , 144 , 168 ,
843
+ 106 , 9 , 162 , 178 , 195 , 134 , 64 , 92 , 47 , 116 , 42 , 248 , 66 >> ,
844
+ << 55 , 176 , 184 , 46 , 229 , 216 , 168 , 134 , 114 , 223 , 56 , 149 , 164 , 106 , 244 , 139 , 188 , 211 ,
845
+ 13 , 110 , 252 , 201 , 8 , 19 , 110 , 41 , 69 , 111 , 163 , 6 , 4 , 187 >>
846
+ ]
847
+ ] ,
848
+ [
849
+ << 160 , 184 , 105 , 145 , 198 , 33 , 139 , 54 , 193 , 209 , 157 , 74 , 46 , 158 , 176 , 206 , 54 , 6 , 235 ,
850
+ 72 >> ,
851
+ [
852
+ << 55 , 87 , 12 , 241 , 140 , 109 , 149 , 116 , 74 , 21 , 79 , 162 , 177 , 155 , 126 , 149 , 140 , 120 ,
853
+ 239 , 104 , 184 , 198 , 10 , 128 , 220 , 82 , 127 , 193 , 94 , 44 , 235 , 143 >> ,
854
+ << 110 , 137 , 211 , 30 , 63 , 216 , 210 , 191 , 11 , 65 , 28 , 69 , 142 , 152 , 199 , 70 , 59 , 247 , 35 ,
855
+ 135 , 140 , 60 , 232 , 168 , 69 , 188 , 249 , 220 , 59 , 46 , 57 , 23 >>
856
+ ]
857
+ ]
858
+ ]
859
+ end
743
860
end
0 commit comments