| 242 | } |
| 243 | |
| 244 | func getPayment(l1Client *eth.PollingClient, contract common.Address, batch uint64) (*big.Int, error) { |
| 245 | uint256Type, _ := abi.NewType("uint256", "", nil) |
| 246 | dataField, _ := abi.Arguments{{Type: uint256Type}}.Pack(new(big.Int).SetUint64(batch)) |
| 247 | h := crypto.Keccak256Hash([]byte(`upfrontPaymentInBatch(uint256)`)) |
| 248 | calldata := append(h[0:4], dataField...) |
| 249 | msg := ethereum.CallMsg{ |
| 250 | To: &contract, |
| 251 | Data: calldata, |
| 252 | } |
| 253 | bs, err := l1Client.CallContract(context.Background(), msg, nil) |
| 254 | if err != nil { |
| 255 | lg.Error("Failed to call contract", "error", err.Error()) |
| 256 | return nil, err |
| 257 | } |
| 258 | return new(big.Int).SetBytes(bs), nil |
| 259 | } |
| 260 | |
| 261 | func prepareData(t *testing.T, l1Client *eth.PollingClient, storageMgr *ethstorage.StorageManager) { |
| 262 | // fill contract with almost 2 shards of blobs |